QString linking error with visual studio 2013 ( nmake tool ) and Qt 5.4
-
I'm getting linking error with QString even with simple code like the following
@#include <QString>
int main()
{
QString str;return 0;
}@This is the .pro
@QT += core
QT -= guiTEMPLATE = app
TARGET = test
CONFIG += console debug
SOURCES += main.cpp@I'm using Visual Studio 2013 and Qt 5.4. This is the error
@Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved."C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe" -f Makefile.Debug
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.cl -c -nologo -Zm200 -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc /Fddebug\test.pdb -DUNICODE -DWIN32
I"......\Qt\5.4\msvc2013_64\include" -I"......\Qt\5.4\msvc2013_64\include\QtCore" -I"debug" -I"......\Qt\5.4\msvc2
win32-msvc2013" -Fodebug\ @C:\Users\XXXX\AppData\Local\Temp\nm7B85.tmp
main.cpp
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.
Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /O
xe @C:\Users\XXXX\AppData\Local\Temp\nm84F8.tmp
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::QString(void)" (
g@@QAE@XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QString::~QString(void)"
ng@@QAE@XZ) referenced in function _main
debug\test.exe : fatal error LNK1120: 2 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.@qmake is located in
@C:\Qt\5.4\msvc2013_64\bin@and I'm using cmd for x84. Does this cause the problem?
-
of course you should use the x64 command line. VS provides a shortcut for it.
For example the one which calls:
@
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"" amd64
@
I don't know if that's the problem though, because i would expect an other linker error. But nevertheless you must use the x64 msvc build tools when using x64 Qt binaries. -
Hi,
Yes it does. From what you wrote, you are trying to compile a 32bit application with a 64bit Qt version
-
No, only when you download the x64 binaries of Qt. Of course there are also x86 binaries available.
-
@raven-worx, when I go to the download page, there is only one link and there is a green message called "Recommended...":http://www.qt.io/download-open-source/. Where is the version that supports both?
-
goto the downloads page (the site you posted the link). Then on top choose "Qt Offline Installers". There are the versions listed for different compilers.
For the msvc2013 binaries the 32bit and 64bit version are available also OpenGL and Angle variants. -
[quote author="CroCo" date="1422607745"]Now it is working. Thank you so much. But where is the version of Qt that supports both versions x86 and x64?[/quote]
You can run 32bit applications on a 64bit system but not vice versa.
So in most cases you don't need to build a 64bit version, only when you know why you have to choose 64bit. In case you don't know, go with the 32bit version ;)