Hi,

Today, I started to compile QT 4.1.1 using VC++ 8.0.
I followed instructions explained in this wikipage Compiling Qt4 on Windows.

After some time of compilation I got first error, I managed to fix it but shortly then I started to get next errors related to the same issue but for different files.
Below I'll try to explain what is the error about and how did I fix it.
I have no idea why I got those errors. Simply, it's a very strange situation

I put QT 4.1.1 sources to C:\Lib\qt\4.1.1\

Problem:

Shortly, all errors was from linker which complained that some object files can not be found, e.g.
LINK : fatal error LNK1181: cannot open input file 'tmp\obj\release_shared\qrc_pathstroke.obj'

After short investigation I revealed that qrc_*.cpp files were not compiled, so no qrc_*.obj files were produced too.

I got this kind of error for many QT4 modules and files. First file that was not compiled was qrc_qstyle.cpp. Also, I met this problem with different qrc_*.cpp/.obj files in all demos (in my case located here C:\Lib\qt\4.1.1\demos).

So, I'll try to explain details of the problem taking pathstroke demo (C:\Lib\qt\4.1.1\demos\pathstroke).

Here is last part of nmake output with error message:

Qt Code:
  1. C:\Lib\qt\4.1.1\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBU
  2. G -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DWIN32 -I"C:/Lib/qt/4.1.1/include/QtCore
  3. " -I"C:/Lib/qt/4.1.1/include/QtGui" -I"C:/Lib/qt/4.1.1/include" -I"..\shared" -I"C:/Lib/qt
  4. /4.1.1/include/ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:/Lib/qt/4.1.1/mkspecs/win32
  5. -msvc2005" -DWIN32 pathstroke.h -o tmp\moc\release_shared\moc_pathstroke.cpp
  6. C:\Lib\qt\4.1.1\bin\rcc.exe -name pathstroke pathstroke.qrc -o tmp\rcc\release_sha
  7. red\qrc_pathstroke.cpp
  8. cl -c -nologo -Zm200 -GS -wd4996 -O2 -MD -GR -EHsc -W3 -DUNICODE -DQT_LARGEFILE_SU
  9. PPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DWIN32 -I"C:/
  10. Lib/qt/4.1.1/include/QtCore" -I"C:/Lib/qt/4.1.1/include/QtGui" -I"C:/Lib/qt/4.1.1/include"
  11. -I"..\shared" -I"C:/Lib/qt/4.1.1/include/ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:
  12. /Lib/qt/4.1.1/mkspecs/win32-msvc2005" -Fotmp\obj\release_shared\ @C:\DOCUME~1\MLOSKO~1.TAX
  13. \USTAWI~1\Temp\nm300E.tmp
  14. main.cpp
  15. pathstroke.cpp
  16. Generating Code...
  17. cl -c -nologo -Zm200 -GS -wd4996 -O2 -MD -GR -EHsc -W3 -DUNICODE -DQT_LARGEFILE_SU
  18. PPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DWIN32 -I"C:/
  19. Lib/qt/4.1.1/include/QtCore" -I"C:/Lib/qt/4.1.1/include/QtGui" -I"C:/Lib/qt/4.1.1/include"
  20. -I"..\shared" -I"C:/Lib/qt/4.1.1/include/ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:
  21. /Lib/qt/4.1.1/mkspecs/win32-msvc2005" -Fotmp\obj\release_shared\ @C:\DOCUME~1\MLOSKO~1.TAX
  22. \USTAWI~1\Temp\nm300F.tmp
  23. moc_pathstroke.cpp
  24. link /LIBPATH:"C:\Lib\qt\4.1.1\lib" /LIBPATH:"C:\Lib\qt\4.1.1\lib" /NOLOGO /SUBSYS
  25. TEM:WINDOWS /incremental:no /OUT:"release\pathstroke.exe" @C:\DOCUME~1\MLOSKO~1.TAX\USTAWI
  26. ~1\Temp\nm3010.tmp
  27. LINK : fatal error LNK1181: cannot open input file 'tmp\obj\release_shared\qrc_pathstroke.
  28. obj'
  29. NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\link.EXE"'
  30. : return code '0x49d'
  31. Stop.
  32. NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\nmake.EXE"'
  33. : return code '0x2'
  34. Stop.
  35. NMAKE : fatal error U1077: 'cd' : return code '0x2'
  36. Stop.
  37. NMAKE : fatal error U1077: 'cd' : return code '0x2'
  38. Stop.
To copy to clipboard, switch view to plain text mode 

As you can see, the error message is about qrc_*.obj file:

LINK : fatal error LNK1181: cannot open input file 'tmp\obj\release_shared\qrc_pathstroke.obj'

qrc_pathstroke.cpp file exists where it should (here: tmp\rcc\release_shared\qrc_pathstroke.cpp) because as you can see above it was generated with following command:

C:\Lib\qt\4.1.1\bin\rcc.exe -name pathstroke pathstroke.qrc -o tmp\rcc\release_shared\qrc_pathstroke.cpp

The question is why qrc_pathstroke.cpp file is not compiled?

OK, let's look into makefiles (Makefile.Debug and Makefile.Release):

Qt Code:
  1. SOURCES = main.cpp \
  2. pathstroke.cpp tmp\moc\debug_shared\moc_pathstroke.cpp \
  3. tmp\rcc\debug_shared\qrc_pathstroke.cpp
  4. OBJECTS = tmp\obj\debug_shared\main.obj \
  5. tmp\obj\debug_shared\pathstroke.obj \
  6. tmp\obj\debug_shared\moc_pathstroke.obj \
  7. tmp\obj\debug_shared\qrc_pathstroke.obj
To copy to clipboard, switch view to plain text mode 

Yes, I said qrc_pathstroke.cpp is not compiled.
nmake output displays (lines 17-23 in nmake output above) that moc_pathstroke.cpp is compiled and just after this file qrc_pathstroke.cpp should be compiled too. But it isn't.
Again, I double checked this file really lives in expected location: tmp\rcc\debug_shared\qrc_pathstroke.cpp.

So, what's going wrong with this makefile?
Are there any wrong characters, espace sequences in path like \r or \c?
I don't see anything suspicious there!

Solution:

NOTE: This solution is very provisional, but I have no idea how to solve it better.

Here is how I managed to build QT inspite of those errors:
1. For every module that give error presented above you need to edit Makefile.Debug and Makefile.Release. In SOURCES section remove path part for qrc_*.cpp file:

Original makefile content:
Qt Code:
  1. SOURCES = main.cpp \
  2. pathstroke.cpp tmp\moc\debug_shared\moc_pathstroke.cpp \
  3. tmp\rcc\debug_shared\qrc_pathstroke.cpp
To copy to clipboard, switch view to plain text mode 

Changed makefile content:
Qt Code:
  1. SOURCES = main.cpp \
  2. pathstroke.cpp tmp\moc\debug_shared\moc_pathstroke.cpp \
  3. qrc_pathstroke.cpp
To copy to clipboard, switch view to plain text mode 

2. Go to tmp\rcc\debug_shared\ directory. Full path of this directory in my environment is:
C:\Lib\qt\4.1.1\demos\pathstroke\tmp\rcc\debug_sha red

3. Copy qrc_pathstroke.cpp file from
C:\Lib\qt\4.1.1\demos\pathstroke\tmp\rcc\debug_sha red
to root directory of module:
C:\Lib\qt\4.1.1\demos\pathstroke\

4. Run nmake again and now nmake will find qrc_pathstroke.cpp file to build qrc_pathstroke.obj object file. Finally, linker will not complain


Next, you will likely get another similar error message about missing some qrc_*.obj file,
so for every such error case you have to repeat steps presented above.

The most important question is Why it is behaving that way?
What causes those problems?

NOTE:
I use QT 4.1.1 Open Source Edition, because I'm going to develop Open Source (GPL) software. But I have my copy of VC++ 8.0 so I want to use this as a compiler, instead of MinGW.
I know Trolltech does not support OS Editon of QT with VC++ compiler, so I hope someone from Community will be able to help me.
May be this is an unknown bug yet, so my post will be helpful for others.

Cheers