Seite 1 von 1
Einbinden von Qt in Visual Studio C++ 6.0
Verfasst: 27. April 2005 16:46
von JPSelter
Im Rahmen eines Uni-Praktikums sollen wir jetzt ein OpenGL Programm schreiben, in C++ und mit Qt. Aber im Moment scheitere ich dabei, Qt (3.2.2.Educational) in Visual Studio C++ 6.0 einzubinden.
Ganz am Anfang brachte der Linker 21 Fehlermeldungen "unresolved external symbol". Dann habe ich unter "Project -> Settings -> Link" explizit alle *.lib Dateien eingegeben, die im Qt-Lib Verzeichnis stehen. Ausserdem habe ich die Ordner /qt/lib und /qt/include in die globalen Verzeichnis-Settings eingetragen.
Jetzt bekomme ich nur noch eine einzige Fehlermeldung (vom Linker, der Compiler läuft aber normal durch):
--------------------Configuration: main - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol "public: __thiscall MyMainWindow::MyMainWindow(class QApplication *)" (??0MyMainWindow@@QAE@PAVQApplication@@@Z)
Debug/main.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
main.exe - 2 error(s), 0 warning(s)
Woran kann das liegen? Fehlt irgendwo noch etwas? Mir wurde gesagt, es könnte an moc liegen, dass ich das noch irgendwo angeben müsse, aber ich weiss nicht wo ich das kann.
Hat jemand eine Schritt-für-Schritt-Anleitung für die Qt-Installation?
Verfasst: 27. April 2005 18:04
von Christian81
Verfasst: 27. April 2005 19:22
von JPSelter
Gilt das auch für Windows2000?
Inzwischen bin ich etwas weitergekommen und bekomme nun andere Fehlermeldungen. Vielleicht ist das Problem hier deutlicher zu sehen:
--------------------Configuration: main - Win32 Debug--------------------
Linking...
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyGLFrame::qt_property(int,int,class QVariant *)" (?qt_property@MyGLFrame@@UAE_NHHPAVQVariant@@@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyGLFrame::qt_emit(int,struct QUObject *)" (?qt_emit@MyGLFrame@@UAE_NHPAUQUObject@@@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyGLFrame::qt_invoke(int,struct QUObject *)" (?qt_invoke@MyGLFrame@@UAE_NHPAUQUObject@@@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall MyGLFrame::qt_cast(char const *)" (?qt_cast@MyGLFrame@@UAEPAXPBD@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall MyGLFrame::className(void)const " (?className@MyGLFrame@@UBEPBDXZ)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: static class QMetaObject * __cdecl MyGLFrame::staticMetaObject(void)" (?staticMetaObject@MyGLFrame@@SAPAVQMetaObject@@XZ)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindow::qt_property(int,int,class QVariant *)" (?qt_property@MyMainWindow@@UAE_NHHPAVQVariant@@@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindow::qt_emit(int,struct QUObject *)" (?qt_emit@MyMainWindow@@UAE_NHPAUQUObject@@@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindow::qt_invoke(int,struct QUObject *)" (?qt_invoke@MyMainWindow@@UAE_NHPAUQUObject@@@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall MyMainWindow::qt_cast(char const *)" (?qt_cast@MyMainWindow@@UAEPAXPBD@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall MyMainWindow::className(void)const " (?className@MyMainWindow@@UBEPBDXZ)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: static class QMetaObject * __cdecl MyMainWindow::staticMetaObject(void)" (?staticMetaObject@MyMainWindow@@SAPAVQMetaObject@@XZ)
Debug/main.exe : fatal error LNK1120: 12 unresolved externals
Error executing link.exe.
main.exe - 13 error(s), 0 warning(s)
Ich denke irgendwelche Bibliotheken fehlen, ich habe aber alle in den Projectsettings angegeben (einfach alle *.lib eingetragen).
Auch die MOC Geschichte fehlt noch, der Tutor meinte eben ich soll das unter "Custom Build Step" eintippen, aber bei mir sieht Visual Studio anders aus, als bei ihm und hier heisst es auch nur "Custom Build". Dort kann ich zwar ein Command eintippen, aber auch zwingend etwas bei "Outputs", nur was?
Verfasst: 27. April 2005 19:41
von Christian81
JPSelter hat geschrieben:Gilt das auch für Windows2000?
Wieso sollte es nicht?
Nimm endlich qmake, dann siehst du wie es eingetragen wird!
Verfasst: 27. April 2005 21:25
von JPSelter
Christian81 hat geschrieben:
Nimm endlich qmake, dann siehst du wie es eingetragen wird!
Jawoll, Sir!
Verfasst: 29. April 2005 07:24
von Christian81
und Lösung gefunden?
Grundsätzlich sollte man wohl eher qmake verwenden als von Hand ein Projekt in MSVC anzulegen. So werden die moc und uic-Dateien automatisch richtig behandelt. Ausserdem hat man so die Möglichkeit, dies auch mit einem anderen Compiler zu kompilieren indem man einfach QMAKESPEC anders setzt.
Verfasst: 29. April 2005 17:22
von JPSelter
Habe gestern VS6.0 in die Tonne gekloppt und Visual C++ .NET 2005 Beta 2 installiert. Ich warte aber gerade auf die fertige Projektdatei von meinem Praktikums-Kollegen, bei ihm lief alles nach einigem tweaken.
Verfasst: 29. April 2005 18:26
von Goos
JPSelter hat geschrieben:--------------------Configuration: main - Win32 Debug--------------------
Linking...
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyGLFrame::qt_property(int,int,class QVariant *)" (?qt_property@MyGLFrame@@UAE_NHHPAVQVariant@@@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyGLFrame::qt_emit(int,struct QUObject *)" (?qt_emit@MyGLFrame@@UAE_NHPAUQUObject@@@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyGLFrame::qt_invoke(int,struct QUObject *)" (?qt_invoke@MyGLFrame@@UAE_NHPAUQUObject@@@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall MyGLFrame::qt_cast(char const *)" (?qt_cast@MyGLFrame@@UAEPAXPBD@Z)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall MyGLFrame::className(void)const " (?className@MyGLFrame@@UBEPBDXZ)
MyGLFrame.qt.obj : error LNK2001: unresolved external symbol "public: static class QMetaObject * __cdecl MyGLFrame::staticMetaObject(void)" (?staticMetaObject@MyGLFrame@@SAPAVQMetaObject@@XZ)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindow::qt_property(int,int,class QVariant *)" (?qt_property@MyMainWindow@@UAE_NHHPAVQVariant@@@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindow::qt_emit(int,struct QUObject *)" (?qt_emit@MyMainWindow@@UAE_NHPAUQUObject@@@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindow::qt_invoke(int,struct QUObject *)" (?qt_invoke@MyMainWindow@@UAE_NHPAUQUObject@@@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall MyMainWindow::qt_cast(char const *)" (?qt_cast@MyMainWindow@@UAEPAXPBD@Z)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall MyMainWindow::className(void)const " (?className@MyMainWindow@@UBEPBDXZ)
MyMainWindow.qt.obj : error LNK2001: unresolved external symbol "public: static class QMetaObject * __cdecl MyMainWindow::staticMetaObject(void)" (?staticMetaObject@MyMainWindow@@SAPAVQMetaObject@@XZ)
Debug/main.exe : fatal error LNK1120: 12 unresolved externals
Error executing link.exe.
main.exe - 13 error(s), 0 warning(s)
Das ist sehr typisch fuer fehlende moc-Files.
Ich kann allerdings nicht sagen, ob die Educational Edition ebenso wie die Enterprise Edition auch ein AddIn fuer Visual Studio mitbringt. Falls doch, dann ists nur noch einzubinden und bei den entsprechenden Header-Files der MOC-Button zu druecken.
Goos
Verfasst: 3. Juni 2005 09:57
von Carsten
Bei eigenen OpenGl Projekten fehlen bei der Qt 3.2.1 und 2.3 Non Commercial Version die Eintraege fuer die GL-Libaries.
.: Unter 'Projekt->Projekteinstellungen->Linker->Objekt/Module' nachtragen bzw. aus den Qt excample hinein kopieren.