views:

359

answers:

2

While attempting to link with QT 4.5 release, I run into this error message

fatal error C1047: The object or library file 'c:\qt\2009.02\qt\lib\qtmain.lib' was created with an older compiler than other objects; rebuild old objects and libraries

I have been using the same compiler for my current projects to compile QT 4.5 (VS 2005, though I am not sure if I compile it with VS2005 SP1 or not, but I am using SP1 now). The problem only rears its head when another library I am compiling with has GL enabled (which switched to LTCG automatically by VS2005). I only could get the build to work if I disable all optimization in all other libraries (which prevent LTCG from being enabled)

Is there a way to get QT 4.5 to work with LTCG release build process? If I have to recompile, what flags need I to set for nmake?

By the way, the project is created with QT 4.5 Visual Studio Add-in, and for the release build it has GL turned off automatically.

A: 

I just ran into a similar problem while trying to build the examples in Qwt and did the same thing you did -- I removed the -GL switch from all of the Makefiles (Makefile.Release). A bit of a pain but all the examples now run.

From the comments in this thread it looks like Qt 4.5.0 now uses the /GL and /LTCG flags.

Update 2010-01-14 New method to just get rid of the whole -GL / -LTCG issue:

Edit C:\Qt\4.5.1\mkspecs\win32-msvc2008\qmake.conf (or the one that corresponds to your version of MSVC) and change the lines

QMAKE_CFLAGS_RELEASE    = -O2 -MD -GL

to

QMAKE_CFLAGS_RELEASE    = -O2 -MD

and

QMAKE_LFLAGS_RELEASE    = /INCREMENTAL:NO /LTCG

to

QMAKE_LFLAGS_RELEASE    = /INCREMENTAL:NO

Now any Makefile that is created will not have these flags present.

Update 2010-03-22 It appears Qt 4.6.1 has fixed the original issue. Give it a spin.

dwj
I am using Qt 4.5.0, which is what frustrates me
Extrakun
A: 

On a closer look at the complie options for QT 4.5, there is a flag to enable LTCG. It is disabled by default.

Extrakun
Did you recompile Qt?
dwj