Einbinden von Qt in Visual Studio C++ 6.0
Einbinden von Qt in Visual Studio C++ 6.0
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?
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?
-
- Beiträge: 7319
- Registriert: 26. August 2004 14:11
- Wohnort: Bremen
- Kontaktdaten:
Siehe hier
http://doc.trolltech.com/3.3/qmake-manual.html
http://doc.trolltech.com/3.3/qmake-manu ... l#TEMPLATE (hier speziell 'vcapp')
http://doc.trolltech.com/3.3/qmake-manual.html
http://doc.trolltech.com/3.3/qmake-manu ... l#TEMPLATE (hier speziell 'vcapp')
MfG Christian
'Funktioniert nicht' ist keine Fehlerbeschreibung
'Funktioniert nicht' ist keine Fehlerbeschreibung
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?
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?
-
- Beiträge: 7319
- Registriert: 26. August 2004 14:11
- Wohnort: Bremen
- Kontaktdaten:
-
- Beiträge: 7319
- Registriert: 26. August 2004 14:11
- Wohnort: Bremen
- Kontaktdaten:
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.
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.
MfG Christian
'Funktioniert nicht' ist keine Fehlerbeschreibung
'Funktioniert nicht' ist keine Fehlerbeschreibung
Das ist sehr typisch fuer fehlende moc-Files.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)
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