PDA

View Full Version : [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files



mloskot
4th March 2006, 22:39
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 (http://psi-im.org/wiki/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 :rolleyes:

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:


C:\Lib\qt\4.1.1\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBU
G -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DWIN32 -I"C:/Lib/qt/4.1.1/include/QtCore
" -I"C:/Lib/qt/4.1.1/include/QtGui" -I"C:/Lib/qt/4.1.1/include" -I"..\shared" -I"C:/Lib/qt
/4.1.1/include/ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:/Lib/qt/4.1.1/mkspecs/win32
-msvc2005" -DWIN32 pathstroke.h -o tmp\moc\release_shared\moc_pathstroke.cpp
C:\Lib\qt\4.1.1\bin\rcc.exe -name pathstroke pathstroke.qrc -o tmp\rcc\release_sha
red\qrc_pathstroke.cpp
cl -c -nologo -Zm200 -GS -wd4996 -O2 -MD -GR -EHsc -W3 -DUNICODE -DQT_LARGEFILE_SU
PPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DWIN32 -I"C:/
Lib/qt/4.1.1/include/QtCore" -I"C:/Lib/qt/4.1.1/include/QtGui" -I"C:/Lib/qt/4.1.1/include"
-I"..\shared" -I"C:/Lib/qt/4.1.1/include/ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:
/Lib/qt/4.1.1/mkspecs/win32-msvc2005" -Fotmp\obj\release_shared\ @C:\DOCUME~1\MLOSKO~1.TAX
\USTAWI~1\Temp\nm300E.tmp
main.cpp
pathstroke.cpp
Generating Code...
cl -c -nologo -Zm200 -GS -wd4996 -O2 -MD -GR -EHsc -W3 -DUNICODE -DQT_LARGEFILE_SU
PPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DWIN32 -I"C:/
Lib/qt/4.1.1/include/QtCore" -I"C:/Lib/qt/4.1.1/include/QtGui" -I"C:/Lib/qt/4.1.1/include"
-I"..\shared" -I"C:/Lib/qt/4.1.1/include/ActiveQt" -I"tmp\moc\release_shared" -I"." -I"C:
/Lib/qt/4.1.1/mkspecs/win32-msvc2005" -Fotmp\obj\release_shared\ @C:\DOCUME~1\MLOSKO~1.TAX
\USTAWI~1\Temp\nm300F.tmp
moc_pathstroke.cpp
link /LIBPATH:"C:\Lib\qt\4.1.1\lib" /LIBPATH:"C:\Lib\qt\4.1.1\lib" /NOLOGO /SUBSYS
TEM:WINDOWS /incremental:no /OUT:"release\pathstroke.exe" @C:\DOCUME~1\MLOSKO~1.TAX\USTAWI
~1\Temp\nm3010.tmp
LINK : fatal error LNK1181: cannot open input file 'tmp\obj\release_shared\qrc_pathstroke.
obj'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\link.EXE"'
: return code '0x49d'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\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.

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):


SOURCES = main.cpp \
pathstroke.cpp tmp\moc\debug_shared\moc_pathstroke.cpp \
tmp\rcc\debug_shared\qrc_pathstroke.cpp
OBJECTS = tmp\obj\debug_shared\main.obj \
tmp\obj\debug_shared\pathstroke.obj \
tmp\obj\debug_shared\moc_pathstroke.obj \
tmp\obj\debug_shared\qrc_pathstroke.obj

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:

SOURCES = main.cpp \
pathstroke.cpp tmp\moc\debug_shared\moc_pathstroke.cpp \
tmp\rcc\debug_shared\qrc_pathstroke.cpp

Changed makefile content:

SOURCES = main.cpp \
pathstroke.cpp tmp\moc\debug_shared\moc_pathstroke.cpp \
qrc_pathstroke.cpp

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 :D


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

jacek
4th March 2006, 22:49
http://www.qtcentre.org/forum/showthread.php?t=941 (make sure you read BrainB0ne's answer).

mloskot
4th March 2006, 23:07
Hi,

I've applied this patch.
As I said, I followed instructions from this page
http://psi-im.org/wiki/Compiling_Qt4_on_Windows
and there is note about this patch (http://psi-im.org/wiki/Compiling_Qt4_on_Windows#Compiling_Qt4_using_Micro soft_Visual_C.2B.2B_.28unsupported.29)
So, I have it applied correctly.

jacek
4th March 2006, 23:10
As I said, I followed instructions from this page
http://psi-im.org/wiki/Compiling_Qt4_on_Windows
and there is note about this patch (http://psi-im.org/wiki/Compiling_Qt4_on_Windows#Compiling_Qt4_using_Micro soft_Visual_C.2B.2B_.28unsupported.29)
But instructions on this page and link to the patch are for Qt 4.1.0 and you are using Qt 4.1.1 --- try the newer version of this patch (which you can find, when you follow the link in mentioned post).

mloskot
5th March 2006, 00:20
But instructions on this page and link to the patch are for Qt 4.1.0 and you are using Qt 4.1.1 --- try the newer version of this patch

Definitely, you were right!
I overlooked this detail to check proper version of the QT patch.
Hehe, it seems I've lost 2 hours playing with my own solution instead of using the right patch.
I feel pretty dump :D

Thank!

ChristianEhrlicher
6th March 2006, 07:42
I've fixed the psi-im wiki to point to the dowload section of qtwin instead the deeplink to the (outdated) patch.

mloskot
6th March 2006, 11:28
I've fixed the psi-im wiki to point to the dowload section of qtwin instead the deeplink to the (outdated) patch.

Thanks, that will be helpful.
It could be fine to link to general download website where patch can be found and inform user to select latest patch appropriate for QT version used by user.

Cheers