PDA

View Full Version : qmake VERSION variable breaks my code on MSVC2010 with qt4.7.3



redoctober0
10th June 2011, 17:38
Ok so here's what i'm talking about. I upgraded from qt4.7.0 to qt4.7.3 and from msvc2008 to msvc2010 on Win7x64 and when i compiled my code i ran into a problem which i wasn't having before, namely the target application name had a VER_MAJ number appended to it (which wasn't happening in the previous setup). More than that, i started getting compilation error messages like these:


C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuil d.targets(990,5): warning MSB8012: TargetPath(D:\tmp\QTTest\debug\QTTest1.exe) does not match the Linker's OutputFile property value (D:\tmp\QTTest\debug\QTTest.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuil d.targets(992,5): warning MSB8012: TargetName(QTTest1) does not match the Linker's OutputFile property value (QTTest). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

So i created a test project just to play around with it. Here's my .pro file:


TEMPLATE = vcapp
CONFIG += qt thread warn_on debug_and_release build_all largefile
QT += xml
INCLUDEPATH += ./GeneratedFiles

TARGET = QTTest
VERSION = 1.0.1
DEPENDPATH += .
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles

HEADERS += ./TestDialog.h
SOURCES += ./TestDialog.cpp \
./main.cpp
FORMS += ./TestDialog.ui

The main.cpp file is this:


#include <QtGui/QApplication>
#include "TestDialog.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
TestDialog w;
w.show();
return a.exec();
}

And the TestDialog.* are just an auto-generated empty dialog files.

Now, if i remove line 7 (VERSION = 1.0.1) from the .pro file everything compiles and runs fine, but with the VERSION variable present i get the errors posted above and even though it says that compilation is successful the application crashes at the start up. In the project settings TargetName is set to QTTest1 but in the Linker.OutputFile it is set to QTTest which is what causes the problem. If i manually change one of them so that they match project compiles and runs perfectly.

My question is: is it me who's doing something wrong here or is it a bug with qmake? And how do i fix it? Mind you, everything was working fine with the previous versions of qt and msvc. Ideally i would like to remove version number from the executable's name and still keep using the VERSION in .pro file, but after searching around it looks like that's impossible to do.

Does anybody have any ideas? I appreciate any help.

mvuori
11th June 2011, 09:25
Just a suggestion: you changed two things at one step -- Qt version and compiler and that makes correcting things difficult. If (and you should) you have the old compiler on you PC, try using it with the new Qt to see which one causes the problem.

redoctober0
13th June 2011, 15:29
Good point. I just ran qmake with msvc2008 settings and compiled it with msvc2008 and everything works fine. And it works fine because the version number is NOT appended to the target file. In fact there is no separate field in msvc2008 project settings for Target Name as there is in msvc2010. So i'm still thinking it's a qmake bug.

But i was wondering if anyone can actually replicate this error to make sure that it's not just a problem with my setup.

P.S.: I'm attaching the project files i used to make it easier for people try to replicate this problem.