OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

First recipe from cookbook won't compile with given source code


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Rodrigo
User


Joined: 01 Mar 2017
Posts: 24

PostPosted: Thu Jan 17, 2019 2:42 am    Post subject:
First recipe from cookbook won't compile with given source code
Reply with quote

Hi,

I'm following the OpenSceneGraph 3 Cookbook to learn more about OSG. So I created a directory Cookbook following the directory structure from the source code here.

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:

Quote:
$ 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:

Quote:
$ 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
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 514
Location: France

PostPosted: Sat Jan 19, 2019 1:39 am    Post subject:
Re: First recipe from cookbook won't compile with given source code
Reply with quote

Hi
use cmake with provided CMakelist.txt (https://github.com/xarray/osgRecipes)
Cheers
Rodrigo wrote:
Hi,

I'm following the OpenSceneGraph 3 Cookbook to learn more about OSG. So I created a directory Cookbook following the directory structure from the source code here.

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:

Quote:
$ 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:

Quote:
$ 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.oSad.data.rel.ro._ZTV18RemoveShapeHandler[_ZTV18RemoveShapeHandler]+0xb8): undefined reference to `osgCookBook::PickHandler::handle(osgGA::GUIEventAdapter const&, osgGA::GUIActionAdapter&)'
/tmp/cca0xsAB.oSad.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x18): undefined reference to `typeinfo for osgCookBook::PickHandler'
/tmp/cca0xsAB.oSad.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0xb8): undefined reference to `osgCookBook::PickHandler::handle(osgGA::GUIEventAdapter const&, osgGA::GUIActionAdapter&)'
/tmp/cca0xsAB.oSad.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0xe0): undefined reference to `typeinfo for osgCookBook::PickHandler'
/tmp/cca0xsAB.oSad.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x218): undefined reference to `typeinfo for osgCookBook::PickHandler'
/tmp/cca0xsAB.oSad.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x428): undefined reference to `typeinfo for osgCookBook::PickHandler'
/tmp/cca0xsAB.oSad.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

_________________
Twirling twirling twirling toward freedom
Back to top
View user's profile Send private message Visit poster's website
Rodrigo
User


Joined: 01 Mar 2017
Posts: 24

PostPosted: Sat Jan 19, 2019 2:23 am    Post subject:
Reply with quote

Thank you, Julien.

Though there are two different CMakeLists.txt files (https://github.com/xarray/osgRecipes/CMakeLists.txt and https://github.com/xarray/osgRecipes/tree/master/cookbook/CMakeLists.txt), I tried with the first one, because you said so. I had to give a value to the OPENSCENEGRAPH_LIB_DIR (/usr/local/lib64) in CMake, but it still gives me an error:

Quote:
Could NOT find OpenCV (missing: OpenCV_ROOT_DIR OpenCV_LIBRARIES_RELEASE OpenCV_LIBRARIES_DEBUG OpenCV_LIBRARIES)
Could NOT find ALVAR (missing: ALVAR_ROOT_DIR ALVAR_INCLUDE_DIRS ALVAR_LIBRARIES_RELEASE ALVAR_LIBRARIES_DEBUG ALVAR_LIBRARIES)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GLEW_LIBRARY
linked by target "osgnanovg" in directory /home/rodrigo/Videos/osg/rodrigo/osgRecipes-master/integrations/osgnanovg

Configuring incomplete, errors occurred!
See also "/home/rodrigo/Videos/osg/rodrigo/osgRecipes-build/CMakeFiles/CMakeOutput.log".
See also "/home/rodrigo/Videos/osg/rodrigo/osgRecipes-build/CMakeFiles/CMakeError.log".


And with this I cannot "make" or "make install" it. The readme gives an even more incomplete direction (say nothing about the OPENSCENEGRAPH_LIB_DIR variable, and why not use the default set by OSG?). Going the way I was going, I managed to compile and run most of the recipes in chapter 2. I wouldn't mind giving up one recipe or another just because I didn't install some obscure library. So, maybe using g++ is an easier option? (This includes me losing years with Borland Delphi, instead of learning and dominating C++ and CMake stuff. Shame on me!)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts How to properly compile osg with EGL ... Omar Álvarez General 12 Wed Jan 23, 2019 12:16 pm View latest post
No new posts Loading osgt from string / Compile re... mmaurus General 2 Mon Jan 21, 2019 11:02 am View latest post
No new posts New glTexStorage code is disrupting F... gwaldron General 14 Thu Aug 09, 2018 8:27 pm View latest post
No new posts EXTERNAL: Re: EXTERNAL: Re: Writing t... Rowley, Marlin R General 0 Wed Apr 18, 2018 2:31 pm View latest post
No new posts EXTERNAL: Re: Writing texture coordin... robertosfield General 1 Sat Apr 14, 2018 5:48 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP