[osg-users] Undefined Symbols in OSG on Mac OS X
Berg, Michael
michaeljberg at gmail.com
Sun Nov 4 11:32:12 PST 2007
I have been developing an OSG application on Linux and recently began
making it cross-platform with OS X 10.5 (Leopard).
Either I'm not doing something correctly for an OS X compile or there is
a bug in the OpenSceneGraph-2.2.0.dmg found at
http://www.openscenegraph.org/files/OpenSceneGraph-2.2.0/OpenSceneGraph-2.2.0.dmg.
I'm using CMake for cross platform builds, and whether I generate a
Makefile or an Xcode build environment, the compile fails on OS X with
this message:
==========
Undefined symbols:
"osg::StateSet::setMode(unsigned int, unsigned int)", referenced from:
_main in main.o
_main in main.o
"osg::Image::readPixels(int, int, int, int, unsigned int, unsigned
int)", referenced from:
screenshot(osg::Camera const&) in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
==========
The offending snippets of code are:
==========
osg::ref_ptr<osg::Group> root = new osg::Group();
osg::ref_ptr<osg::StateSet> state = root->getOrCreateStateSet();
state->setMode(GL_LIGHTING, osg::StateAttribute::ON);
state->setMode(GL_LIGHT0, osg::StateAttribute::ON);
==========
osg::ref_ptr<osg::Image> image = new osg::Image();
image->readPixels(static_cast<int>(viewport->x()),
static_cast<int>(viewport->y()),
static_cast<int>(viewport->width()),
static_cast<int>(viewport->height()),
GL_RGBA, GL_UNSIGNED_BYTE);
==========
This same code compiles and links without any problem on Linux.
On OS X, options passed to the compiler include:
-F/Library/Frameworks \
-framework osg -framework osgDB -framework osgGA \
-framework osgParticle -framework osgUtil \
-framework osgText -framework osgViewer
and I have followed the instructions for installing the OSG frameworks
into /Library/Frameworks.
If I comment out the code that triggers the linking errors, I can get
the code to compile, link, and run.
"otool -L" shows for following for the resulting executable:
==========
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
111.0.0)
@executable_path/../Frameworks/osg.framework/Versions/A/osg
(compatibility version 0.0.0, current version 1.0.0)
@executable_path/../Frameworks/osgDB.framework/Versions/A/osgDB
(compatibility version 0.0.0, current version 1.0.0)
@executable_path/../Frameworks/osgGA.framework/Versions/A/osgGA
(compatibility version 0.0.0, current version 1.0.0)
@executable_path/../Frameworks/osgParticle.framework/Versions/A/osgParticle
(compatibility version 0.0.0, current version 1.0.0)
@executable_path/../Frameworks/osgUtil.framework/Versions/A/osgUtil
(compatibility version 0.0.0, current version 1.0.0)
@executable_path/../Frameworks/osgText.framework/Versions/A/osgText
(compatibility version 0.0.0, current version 1.0.0)
@executable_path/../Frameworks/osgViewer.framework/Versions/A/osgViewer
(compatibility version 0.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version
7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
1.0.0)
==========
So executable is linked against the "osg" framework, and the application
runs successfully (with the features that I commented out to get it to
build disabled of course).
Any ideas? Am I doing something wrong? Or did osg::StateSet::setMode()
and osg::Image::readPixels() not make it into the OS X .dmg file (or not
in a form that can be linked against)?
- Michael Berg
More information about the osg-users
mailing list