Je suis nouveau à Qt, et en essayant de compiler et de lier un simple programme "Hello, World" en utilisant "CL.exe" de Microsoft. Des conseils sur la façon de faire cela?Comment résoudre une erreur de lien avec Qt?
Le programme est le suivant:
#include <QtGui>
int main (int argc, char * argv [])
{
QApplication app (argc, argv) ;
QLabel label ("Hello, world!") ;
label.show() ;
return app.exec() ;
}
Je Compilez et liez avec:
C:\PROGRA~1\MICROS~1.0\VC\bin\cl.EXE -nologo -Zm200 -Zc:wchar_t- -O2 -MD^
-W3 -w34100 -w34189 -DUNICODE^
-DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB^
-DQT_THREAD_SUPPORT -DQT_NO_DYNAMIC_CAST^
-I"C:\Qt\2010.05\qt\include\QtCore"^
-I"C:\Qt\2010.05\qt\include\QtGui"^
-I"C:\Qt\2010.05\qt\include"^
-I"."^
-I"C:\Qt\2010.05\qt\include\ActiveQt"^
-I"release"^
-I"C:\Qt\2010.05\qt\mkspecs\win32-msvc2008"^
-I"C:\Progra~1\MICROS~1.0\VC\include"^
Hello.cpp^
/link /LIBPATH:"C:\Qt\2010.05\qt\lib"^
/LIBPATH:"C:\Progra~1\MICROS~1.0\VC\lib"^
/LIBPATH:"C:\Progra~1\MID05A~1\VC\PLATFO~1\Lib"
Mes erreurs de l'éditeur de liens comprennent:
Hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) pub
lic: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplicatio
[email protected]@[email protected]) referenced in function _main
Hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) pub
lic: virtual __thiscall QLabel::~QLabel(void)" ([email protected]@[email protected]) referen
ced in function _main
Hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) pub
lic: static int __cdecl QApplication::exec(void)" ([email protected]@@SAH
XZ) referenced in function _main
Hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) pub
lic: void __thiscall QWidget::show(void)" ([email protected]@@QAEXXZ) referenc
ed in function _main
.
.
.
Mon fichier Hello.pro contient:
######################################################################
# Automatically generated by qmake (2.01a) Mon Dec 13 15:58:13 2010
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += Hello.cpp
Bonjour.pro maintenant inclus dans la question. – JaysonFix
Réponse: Compilez les bibliothèques à l'aide du compilateur Microsoft à l'aide des projets Visual Studio C: \ Qt \ 2010.05 \ qt \ src \ corelib \ QtCore.vcproj et C: \ Qt \ 2010.05 \ qt \ src \ gui \ QtGui.vcproj. Ensuite, créez un projet Hello dans Visual Studio et, sous Projet ... Propriétés, ajoutez des répertoires sous "C/C++ ... Additional Include Directories", ajoutez le répertoire "... qt \ lib" sous "Lieur ... Général ... Additional Library Directories ", ajoutez" QtCored4.lib et QtGuid4.lib "sous" Linker ... Input ... Dépendances supplémentaires. " Ensuite, construisez le projet. {J'espère que je me suis souvenu de tout!} – JaysonFix