Hi, I'm following the OpenSceneGraph 3 Cookbook (http://ahux.narod.ru/olderfiles/1/OSG3_Cookbook.pdf) to learn more about OSG. So I created a directory Cookbook following the directory structure from the source code here (https://github.com/xarray/osgRecipes/tree/master/cookbook).
Before compiling the first recipe, I had copied the "Common Functions" from the textbook (pages 38-39), into a file called "CommonFunctions". When compiling (with g++ on Linux) I got the following error: > $ g++ observer_ptr.cpp -I../.. -losg -losgDB -losgGA -losgText -losgUtil > -losgViewer -o observer_ptr > > In file included from observer_ptr.cpp:11:0: > ../../CommonFunctions: In member function ‘virtual bool > osgCookBook::PickHandler::handle(const osgGA::GUIEventAdapter&, > osgGA::GUIActionAdapter&)’: > ../../CommonFunctions:47:62: error: binding ‘const > osgUtil::LineSegmentIntersector::Intersection’ to reference of type > ‘osgUtil::LineSegmentIntersector::Intersection&’ discards qualifiers > osgUtil::LineSegmentIntersector::Intersection& result = > *(intersector->getIntersections().begin()); > ../.. is the path to the CommonFunctions file. I tried a few const_cast operations, but I don't have so much experience with C++ and couldn't solve it. I commented out this two lines and the program compiled fine and ran, though clicking on the objects wouldn't dismiss them (guess that's what these lines do). Then I noticed they have this "CommonFunctions" file together with the given source code, so I replaced mine with theirs (CommonFunctions and CommonFunctions.cpp). But when compiling, a new error: > $ g++ observer_ptr.cpp -I../.. -losg -losgDB -losgGA -losgText -losgUtil > -losgViewer -o observer_ptr > > /tmp/cca0xsAB.o: In function `main': > observer_ptr.cpp:(.text+0x79): undefined reference to > `osgCookBook::createText(osg::Vec3f const&, std::__cxx11::basic_string<char, > std::char_traits<char>, std::allocator<char> > const&, float)' > observer_ptr.cpp:(.text+0x103): undefined reference to > `osgCookBook::createHUDCamera(double, double, double, double)' > /tmp/cca0xsAB.o:(.data.rel.ro._ZTV18RemoveShapeHandler[_ZTV18RemoveShapeHandler]+0xb8): > undefined reference to > `osgCookBook::PickHandler::handle(osgGA::GUIEventAdapter const&, > osgGA::GUIActionAdapter&)' > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x18): > undefined reference to `typeinfo for osgCookBook::PickHandler' > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0xb8): > undefined reference to > `osgCookBook::PickHandler::handle(osgGA::GUIEventAdapter const&, > osgGA::GUIActionAdapter&)' > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0xe0): > undefined reference to `typeinfo for osgCookBook::PickHandler' > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x218): > undefined reference to `typeinfo for osgCookBook::PickHandler' > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x428): > undefined reference to `typeinfo for osgCookBook::PickHandler' > /tmp/cca0xsAB.o:(.data.rel.ro._ZTI18RemoveShapeHandler[_ZTI18RemoveShapeHandler]+0x10): > undefined reference to `typeinfo for osgCookBook::PickHandler' > collect2: error: ld returned 1 exit status > Can anybody please tell me what am I doing wrong? Thank you! Cheers, Rodrigo ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=75500#75500 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org