2011-06-29 2 views
1

J'ai des problèmes lors de la construction de OpenCV_HighGui220d.lib avec le support QT. Les problèmes sont les symboles non résolus sur QMetaObject, tels que:Symboles non résolus QMetaObject lors de la construction d'OpenCV avec support QT

public: virtual struct QMetaObject const * __thiscall GuiReceiver::metaObject(void)const ([email protected]@@[email protected]@XZ) 

Mes environnements:
- Visual Studio 2010
- OpenCV 2.2
- QT SDK Version: 4.7.3

Ci-dessous sont mes étapes de construction:
1. utiliser CMake pour ouvrir C:\OpenCV2.2, vérifier WITH_QT et WITH_QT_OPENGL, génère des fichiers vcxproj et sln.

2. AJOUTZ macros dans cvconfig.h:

#define HAVE_QT 
#define HAVE_QT_OPENGL

3. ajouter window_QT.cpp dans le fichier opencv_highgui.vcxproj dans VS2010 et ajouter ci-dessous des macros dans window_QT.cpp
#define QT_LARGEFILE_SUPPORT 
#define QT_DLL 
#define QT_GUI_LIB 
#define QT_CORE_LIB 
#define QT_HAVE_MMX 
#define QT_HAVE_3DNOW 
#define QT_HAVE_SSE 
#define QT_HAVE_MMXEXT 
#define QT_HAVE_SSE2 
#define QT_THREAD_SUPPORT
J'ai essayé aussi de remplacer QT_DLL avec QT_NODLL, mais n'a pas réussi.

4. Ajoutez le répertoire C:/QtSDK/Desktop/Qt/4.7.3/msvc2008/lib dans les répertoires de bibliothèques supplémentaires dans les pages de propriétés du lien.

5. Ajouter ci-dessous dans les bibliothèques Dépendances supplémentaires:
qtmain.lib 
qtmaind.lib 
QtGui4.lib 
QtGuid4.lib 
QtCore4.lib 
QtCored4.lib 
QtOpenGL4.lib 
QtOpenGLd4.lib 
Qt3Support4.lib 
Qt3Supportd4.lib 
QtHelp4.lib 
QtHelpd4.lib 
QtDesigner4.lib 
QtDesignerd4.lib 
QAxContainer.lib 
QAxContainerd.lib 
phonon4.lib 
phonond4.lib 
QAxServer.lib 
QAxServerd.lib 
QtDeclarative4.lib 
QtDeclaratived4.lib 
QtDesignerComponents4.lib 
QtDesignerComponentsd4.lib 
QtMultimedia4.lib 
QtMultimediad4.lib 
QtNetwork4.lib 
QtNetworkd4.lib 
QtScript4.lib 
QtScriptd4.lib 
QtScriptTools4.lib 
QtScriptToolsd4.lib 
QtSql4.lib 
QtSqld4.lib 
QtSvg4.lib 
QtSvgd4.lib 
QtTest4.lib 
QtTestd4.lib 
QtUiTools.lib 
QtUiToolsd.lib 
QtWebKit4.lib 
QtWebKitd4.lib 
QtXml4.lib 
QtXmld4.lib 
QtXmlPatterns4.lib 
QtXmlPatternsd4.lib

6. Enfin, les rapports de l'éditeur de liens d'erreur:

------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------ 
------ Build started: Project: opencv_highgui, Configuration: Debug Win32 ------ 
    Creating library C:/OpenCV2.2/Build_QT/lib/Debug/opencv_highgui220d.lib and object C:/OpenCV2.2/Build_QT/lib/Debug/opencv_highgui220d.exp 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall GuiReceiver::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall GuiReceiver::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GuiReceiver::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvTrackbar::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvTrackbar::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvTrackbar::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const CvTrackbar::staticMetaObject" ([email protected]@@[email protected]@B) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvButtonbar::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvButtonbar::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvButtonbar::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const CvButtonbar::staticMetaObject" ([email protected]@@[email protected]@B) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvPushButton::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvPushButton::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvPushButton::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvCheckBox::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvCheckBox::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvCheckBox::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvRadioButton::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvRadioButton::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvRadioButton::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvWinProperties::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvWinProperties::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvWinProperties::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvWindow::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvWindow::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const CvWindow::staticMetaObject" ([email protected]@@[email protected]@B) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall ViewPort::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall ViewPort::qt_metacast(char const *)" ([email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall ViewPort::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const ViewPort::staticMetaObject" ([email protected]@@[email protected]@B) 
C:\OpenCV2.2\Build_QT\bin\Debug\opencv_highgui220d.dll : fatal error LNK1120: 31 unresolved externals 
========== Build: 1 succeeded, 1 failed, 8 up-to-date, 0 skipped ========== 

Répondre

6

Le Qt MOC (compilateur de méta-objets) n'est pas exécuté sur vos fichiers de classe Qt.

Puisque vous construisez à partir de la version OpenCV, je suppose que les classes d'interface utilisateur ont déjà une ligne Q_OBJECT dans la déclaration de classe.

Pour générer un fichier .vcproj qui a les instructions de construction nécessaires pour exécuter MOC, exécutez la commande suivante:

qmake -tp vc -r <yourProFile.pro> 

Si cela ne fonctionne pas, cliquez droit sur l'un des fichiers .h qui contient un Qt classe. Sous Propriétés-> Construire personnalisée Step-> Général, vous devriez voir quelque chose comme:

Command Line "$(QTDIR)\bin\moc.exe" -I".\GeneratedFiles\." -I"$(QTDIR)\include\." -I".\GeneratedFiles\$(ConfigurationName)\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtGui\." .\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" "-fstdafx.h" "-f[YourQtFile.h]" 
Description Moc'ing $(InputFileName)... 
Outputs ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" 
Additional Dependencies "$(QTDIR)\bin\moc.exe";$(InputPath) 

Hope this helps.

+0

J'ai essayé la commande: 'qmake -tp vc -r opencv_highgui.vcxproj'. Cependant, il rapporte: 'opencv_highgui.vcxproj: 5: Parse Error'' (' Débogage')' 'Erreur lors du traitement du fichier projet: opencv_highgui.vcxproj'. Il semble que qmake ne supporte pas VS2010? – MikimotoH

+0

Terminé. Après avoir essayé la commande ci-dessous pour "moc" manuellement window_QT.h avec Q_OBJECT, ce projet est construit avec succès. Commande: 'moc -I"% QTDIR% \ include "-I"% QTDIR% \ include \ QtCore "-I"% QTDIR% \ include \ QtGui "-omoc_window_QT.cpp window_QT.h' – MikimotoH

+0

Lorsque vous configurez Qt manuellement, win32-msvc2008 est le plus haut descripteur Visual Studio qu'ils ont. Je ne sais pas si VS2010 diffère de manière significative. (Je suis sur VS2005.) Heureux d'entendre que votre problème a été résolu. – Gnawme

0
  1. Add directory C:/QtSDK/Desktop/Qt/4.7.3/msvc2008/lib in Additional Library Directories in Linker Property pages

si vous construisez avec VS2010, je suggère que vous devez ajouter dir avec les bibliothèques compilées avec vs2010 ... votre chemin est probablement fait référence aux libs vs2008.

+0

J'ai installé la dernière version de QT SDK, et il n'y a pas de répertoire nommé 'msvc2010' dans ce répertoire SDK. – MikimotoH

+0

Y a-t-il d'autres fichiers lib autour? J'utilise qt dans Qt bibliothèques édition, il a une autre structure de dossiers .. QMetaObject devrait être dans QtCore4.lib et QtCored4.lib – Raiv

0

Cela peut aider quelqu'un:

j'ai rencontré cette erreur pour une nouvelle classe de QObject j'ai fait, et il alla après qmake réexécution (Build-> qmake Run), puis la reconstruction.

0

si réponse très tard .... J'ai suivi les étapes suivantes pour se débarrasser de l'erreur ci-dessus:

1) Installez OpenSource QT Version ou QT pour la version Visual Studio. 2) Installez Visual Studio QT Addin dans Visual Studio [http://qt.nokia.com/downloads/visual-studio-add-in]. 3) créer un projet utilisant QT et non comme un projet de studio visuel normal. Le projet QT créé deviendra automatiquement un projet de studio visuel. Pour les projets QT existign ..... 1) Ouvrez le projet depuis le menu QT et non depuis le menu Fichier de Visual Studio.

J'espère que cet aide ............... J'ai consommé 2 jours pour que cela fonctionne.

Questions connexes