How to build qt out of source

user152508 picture user152508 · Aug 7, 2009 · Viewed 31k times · Source

I was searching a lot through Qt forums and Google for the last few days, but I could not find any obvious answer to this question.

I found the -prefix option (not even documented on Windows) that can be supplied to configure to specify different install directory, but this is not clear separation of the sources and binaries at all, since the build is still done in the source directory and then the files needed for installation are copied to the install directoy. I tried this -prefix option, and came to some problems. (i.e It doesn't copy the .pdb files to the install directory.)

Then I found this link about doing shadow builds but it has the big limitation that the build dir must be at the same level as the source dir.


I'm guessing you didn't try make install? So try that. It should install Qt to a separate directory away from the sources.

Are you saying that after I do configure, I should do nmake install instead just nmake? I know that nmake will process the generated makefiles from qmake and will place them in the source Qt dir, but what nmake install will exactly do i.e in which directory will install the files and how to specify the directory where the files will be installed.

Note that I already do this:

configure -prefix builddir -platform win32-msvc2005
nmake install

The effect of the above two lines was that qt was compiled in the source dir and not directly to my builddir specified with prefix. Then the compiled files were copied in my builddir. I was hoping for something that will build my Qt files directly to the build dir, cause this way I stil need 4 Gb space for my source dir during the compilation. Also the pdb files were not copied to my buildir which is another issue.

Answer

rohanpm picture rohanpm · Aug 8, 2009

Basically, you just have to run configure.exe from your build directory. For example:

mkdir \qt\4.5.2-build
cd \qt\4.5.2-build
set PATH=%cd%\bin;%PATH%
\qt\4.5.2-sources\configure.exe -platform win32-msvc2005

Where sources are in \qt\4.5.2-sources, that would cause the build to go into \qt\4.5.2-build on the current drive.

Also, you must have perl in your PATH, ActiveState Perl is suggested.

I had not previously heard of this limitation where the build and source directories must be at the same level. If you hit this problem you could try working around it by creating a symbolic link (see mklink command).