Hallo liebes Forum! ;D Ich haben ein Problem beim kompilieren eines openscenegraph-programm.
Ich bin Informatik- und Ubuntuanfänger und gerade beim Thema Computergrafik. Wir sollen für unsere Computergrafik-Programme openscenegraph und Eclipse(CDT-C++) als Entwicklungsumgebung nutzen. Ich habe schon openscenegraph in meinem System eingerichtet und schon ein paar einfache programme geschrieben,die auch funktionieren. Nun hatte ich eine Übung, wo ich noch eine andere lib von osg einbinden muss. Das kompilieren funktioniert leider nicht.
Ich bekomme diese Fehlermeldung beim "build projekt":
/usr/bin/ld: CMakeFiles/CG1_Ue3_Loesung.dir/manipulatoren.cpp.o: undefined reference to symbol 'VTT for osgGA::KeySwitchMatrixManipulator' make[2]: Verlasse Verzeichnis '/home/.../Computergrafik/CG1_Workspace/CG1_Ue3_Loesung/Build' /usr/bin/ld: note: 'VTT for osgGA::KeySwitchMatrixManipulator' is defined in DSO /usr/lib/libosgGA.so.80 so try adding it to the linker command line
Anmerkung: Die ... zwischen home/ und /Computergrafik hab ich jetzt nur für das Frorum gemacht. ;D
Wie im Titel schon beschrieben arbeite ich auch mit cmake.
Ich schildere kurz mal, wie ich meine osg-Programme kompiliere:
Projektordner im Workspace erstellen.
In den Projektordner befindet sich momentan: Das Verzeichnis Build und die Dateien cessna.osg, CMakeLists.txt, manipulatoren.cpp
In Terminal gebe ich dann im Build-Verzeichnis cmake .. ein. Das funktioniert auch.
Dann "binde" ich, dass Projekt in Eclipse ein.
Bei Eclipse mache ich dann "Build Project" und dann kommt der Fehler.
Hier der Code von manipulatoren.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <osg/MatrixTransform> #include <osgDB/ReadFile> #include <osgViewer/Viewer> #include <osgGA/TrackballManipulator> #include <osgGA/DriveManipulator> #include <osgGA/FlightManipulator> #include <osgGA/KeySwitchMatrixManipulator> int main( int argc, char** argv ){ char s=**argv; s++; //osg::ref_ptr<osg::Node> model = osgDB::readNodeFile("cessna.osg"); osg::ref_ptr<osg::Node> model = osgDB::readNodeFile("pitcher.obj"); osg::ref_ptr<osg::MatrixTransform> transformation1 = new osg::MatrixTransform; transformation1->setMatrix( osg::Matrix::translate(-25.0f, 0.0f, 0.0f) ); transformation1->addChild( model.get() ); osg::ref_ptr<osg::MatrixTransform> transformation2 = new osg::MatrixTransform; transformation2->setMatrix( osg::Matrix::translate(25.0f, 0.0f, 0.0f) ); transformation2->addChild( model.get() ); osg::ref_ptr<osg::Group> root = new osg::Group; root->addChild( transformation1.get() ); root->addChild( transformation2.get() ); osgViewer::Viewer viewer; viewer.setSceneData( root.get() ); osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> ksmm = new osgGA::KeySwitchMatrixManipulator; //ksmm->addMatrixManipulator('1',"trackball",new osgGA::TrackballManipulator); ksmm->addMatrixManipulator('2',"drive",new osgGA::DriveManipulator); ksmm->addMatrixManipulator('3',"flight",new osgGA::FlightManipulator); viewer.setCameraManipulator(ksmm.get()); //viewer.setCameraManipulator(new osgGA::TrackballManipulator); return viewer.run(); } |
Hier die Datei CMakeLists.txt:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | cmake_minimum_required( VERSION 2.6 ) project( CG1_Ue3_Loesung ) find_package( OpenThreads ) find_package( osg ) find_package( osgDB ) find_package( osgUtil ) find_package( osgViewer ) find_package( osgGA ) macro( config_project PROJNAME LIBNAME ) include_directories( ${${LIBNAME}_INCLUDE_DIR} ) target_link_libraries( ${PROJNAME} ${${LIBNAME}_LIBRARY} ) endmacro() add_executable( CG1_Ue3_Loesung manipulatoren.cpp ) config_project( CG1_Ue3_Loesung OPENTHREADS ) config_project( CG1_Ue3_Loesung OSG ) config_project( CG1_Ue3_Loesung OSGDB ) config_project( CG1_Ue3_Loesung OSGUTIL ) config_project( CG1_Ue3_Loesung OSGVIEWER ) config_project( CG1_Ue3_Loesung osgGA ) |
Meine Vermutung ist, dass cmake die libosgGA nicht richtig einbindet und dass der Fehler in der Datei CMakeLists.txt liegt. Ich hab auch schon viele Tutorials gelesen und ausprobiert, aber leider noch keine Lösung gefunden. Vielleicht kann mir ja hier jemand helfen! =D
Bearbeitet von rklm:
Formatierung angepasst. Bitte schau Dir die Hilfe zur Syntax an.