2
votes

I want to compile QT statically , I did the following steps:

1)configure -static -debug -opensource

2)nmake sub-src but in this step I have some errors like

D:\qt\bin\rcc.exe -name mimetypes D:\qt-everywhere-opensource-src-5.0.1\ qtbase\src\corelib\mimetypes\mimetypes.qrc -o .rcc\debug_static\qrc_mimetypes.cp p 'D:\qt\bin\rcc.exe' is not recognized as an internal or external command, operable program or batch file. NMAKE : fatal error U1077: 'D:\qt\bin\rcc.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0 \VC\BIN\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.

what should I do?

1

1 Answers

2
votes

Before trying to compile Qt 5.x, you may need to install some libraries (depends of the modules you want to compile) :

  • ActivePerl (** needed, as it is used to configure qtsdk)
  • Microsoft Windows SDK 7.1
  • Microsoft DirectX SDK
  • Python
  • ICU
  • ...

If you plan to use a library (like Assimp for example) which internally use the same libraries (like zlib), you may have to overwrite these libraries, located in the qtbase\src\3rdparty sub-directories, with their latest versions.

Edit the file configure.bat, located in the qtbase directory, and comment out the line 45 :
::if not exist %QTSRC%\.gitignore goto sconf

Edit the file qmake.conf, located in qtbase\mkspecs\win32-msvc2010 (if you're using Visual Studio 2010) or in qtbase\mkspecs\win32-msvc2012 (if you're using Visual Studio 2012) :

  • line 9 : CONFIG += incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target
  • line 23 : QMAKE_CFLAGS_RELEASE = -O2 -MT
  • line 24 : QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
  • line 25 : QMAKE_CFLAGS_DEBUG = -Zi -MTd

Start the Visual Studio command prompt : Start > Programs > Microsoft Visual Studio 20XX > Visual Studio Tools.
Make sure that the path to Perl.exe is in the PATH environment variable : PATH=%PATH%;C:\Perl\bin (or PATH=%PATH%;C:\Perl64\bin if compiling for x64).

Go in the qtbase directory : CD \Qt\5.0.1\qtbase.

Configure Qt for compiling statically debug and release versions :

  • configure -developer-build -opensource -confirm-license -platform win32-msvc2010 -mp -nomake examples -nomake tests -static (if you're using Visual Studio 2010)
  • configure -developer-build -opensource -confirm-license -platform win32-msvc2012 -mp -nomake examples -nomake tests -static (if you're using Visual Studio 2012)

OpenGL-opengl desktop
-mp

Go back in the parent directory : CD ...

Configure again Qt : configure -developer-build -opensource -confirm-license -platform win32-msvc20XX-opengl desktop -mp -nomake examples -nomake tests -static
(I'm not sure this step is needed, but as it takes just a few seconds...).

Compile : nmake.

Another method for compiling is to use jom and specify the number of CPU cores to use : C:\Qt\jom\jom.exe -j #NUMBER_OF_CORES#.

You will find the compiled static libraries in the qtbase\lib folder and the files to include in the sub-directories of qtbase\include.
To use them, you will have to use static run-time libraries (/MT or /MTd) in your Visual C++ project.