Board index FlightGear Support Compiling

Compiling simgear on OSX Yosemite - stops at 97%

Building FlightGear from source, and in the need for help?

Compiling simgear on OSX Yosemite - stops at 97%

Postby Debunque » Wed Nov 12, 2014 11:12 pm

Hello,

I tried to compile FG, and I'm stuck on simgear. I tried to do it two ways: 1) install OpenScenegraph with macports and 2) download all foreign dependencies from Jenkins.

In both cases, the compilation gave what appear to be undefined OSG symbols. Does anyone have any suggestions? Many thanks for any tips.

Code (): Select all
cmake ../simgear-3.2.0 -DCMAKE_INSTALL_PREFIX=/data/Software/Games/FlightGear \

... [compilation proceeds smoothly until 97%]

[ 96%] Built target test_state_machine
Scanning dependencies of target sg_pkgutil
[ 97%] Building CXX object simgear/package/CMakeFiles/sg_pkgutil.dir/pkgutil.cxx.o
Linking CXX executable sg_pkgutil
[ 97%] Built target sg_pkgutil
Scanning dependencies of target test-simgear_canvas_elements-canvas_element
[ 97%] Building CXX object simgear/canvas/elements/CMakeFiles/test-simgear_canvas_elements-canvas_element.dir/canvas_element_test.cpp.o

[NOTE: Lots of compilation warnings and notes about Boost, nothing fatal]

<scratch space>:5:1: note: expanded from here
BIMAP_STATIC_ERROR__const_local_iterator_type_by_FAILURE
^
19 warnings generated.
Linking CXX executable test-simgear_canvas_elements-canvas_element
Undefined symbols for architecture x86_64:
"osgParticle::ParticleSystem::setDefaultAttributes(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, int)", referenced from:
simgear::Particles::appendParticles(SGPropertyNode const*, SGPropertyNode*, osgDB::Options const*) in libSimGearScene.a(particles.cxx.o)
"osg::computeLocalToWorld(std::__1::vector<osg::Node*, std::__1::allocator<osg::Node*> > const&, bool)", referenced from:
SGTrackToAnimation::UpdateCallback::operator()(osg::Node*, osg::NodeVisitor*) in libSimGearScene.a(SGTrackToAnimation.cxx.o)
"osg::computeWorldToLocal(std::__1::vector<osg::Node*, std::__1::allocator<osg::Node*> > const&, bool)", referenced from:

[Lots of more places with undefined symbols]




Machine: 17" 2010 powerbook 8GB ram, OSX 10.10
Simgear: simgear-3.2.0
OSG: both yesterday's from Jenkins, or OpenSceneGraph @3.2.1_1 from Macports - same result as shown above
Boost: boost @1.56.0_2 from MacPorts

Also, Jenkins is giving a lot of problems. All files, zips or not, seem to truncate as the connection is broken. I needed to use wget to get the libraries, using its ability to continue an aborted download. Sometimes wget would have to restart a library in the middle a dozen times.

edit: I also ran cmake forcing it to use the gcc in Macports (rather than /usr/bin/c++), which made it consistent with the compiler used to build Boost and OSG. Still exactly the same error. I also traced the error to the link command in [i]sgbuild/simgear/canvas/elements/CMakeFiles/test-simgear_canvas_elements-canvas_element.dir/link.txt[/i, but this command includes linking to libosgParticle.dylib (which seems to be the source of the missing symbols).
Debunque
 
Posts: 3
Joined: Mon Nov 10, 2014 2:35 am

Re: Compiling simgear on OSX Yosemite - stops at 97%

Postby karam » Mon Feb 16, 2015 11:13 pm

No one has responded to this so I'll share my findings today on the subject.

Starting with Mac OS X 10.9 (Mavericks) Apple changed clang++ C++ runtime library to libc++. The behaviour of clang can be changed with switches and this is done by the OpenSceneGraph maintainers! The OSG maintainers request clang++ to adhere to c++98 and use stdilbc++ runtime rather than the defaults (c++11 and libc++). Subsequently, when compiling simgear the same switches are not utliized by the simgear developers, which I think is a good thing, and compilation fails. The linker expects libc++ usage in simgear whereas OSG has introduced libstdc++.

One must decide which C++ runtime library to use: Apple's libc++, or GCC's libstdc++. MacPorts (http://www.macports.org) uses the same defaults as Apple's compilers and that is reason enough to go with libc++. (Macports behaviour can probably be changed to use libstdc++ but why complicate things?)

The resolution is to recompile and reinstall OSG with proper compiler flags. I use OSG 3.2.x checked out from their subversion repository and make the one change that the maintainers of OSG should do:

Code: Select all
$ svn diff
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt   (revision 14694)
+++ CMakeLists.txt   (working copy)
@@ -836,10 +836,7 @@
         # remain unset.
 
         IF (APPLE)
-            # set standard lib, clang defaults to c++0x
-            set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98")
-            set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
-            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -stdlib=libstdc++ -Wno-overloaded-virtual -Wno-conversion")
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -Wno-conversion")
             set(WARNING_CFLAGS "")
         ENDIF()
 ENDIF()

The whole IF(APPLE) statement could probably be removed.

Hope this helps
karam
 
Posts: 9
Joined: Fri Feb 13, 2015 11:04 am

Re: Compiling simgear on OSX Yosemite - stops at 97%

Postby Debunque » Tue Feb 17, 2015 1:28 am

Thank you very much for your suggestion.

I tried to compile OSG. I think that CMakeLists.txt is already different from the version you posted. For some reason, the compilation failed at link-time, giving a whole pile of undefined symbol errors.

I wanted to compile it to allow use it to use my 3d Connexion mouse, but it is probably a better investment at this point to get a regular joystick.
Debunque
 
Posts: 3
Joined: Mon Nov 10, 2014 2:35 am

Re: Compiling simgear on OSX Yosemite - stops at 97%

Postby karam » Tue Feb 17, 2015 10:27 pm

The latest OSG you can use is the 3.2 branch. Are you sure you have that version of OSG? I checked now, I am on the latest revision on that branch and my compilation works and subsequent compilation of simgear is also good.

Since long I do the below to compile OSG (with the above changes to CMakeLists.txt)

Code: Select all
cd /path/to/osg && mkdir -p build && cd build && \
    cmake .. -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/path/to/localfginstalldir \
    -DCMAKE_CXX_FLAGS=-g 03 \
    -DCMAKE_C_FLAGS=-g 03 \
    -DCMAKE_OSX_ARCHITECTURES=x86_64 \
    -DOSG_WINDOWING_SYSTEM=Cocoa \
    -DOSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX=imageio && \
    make && make install
karam
 
Posts: 9
Joined: Fri Feb 13, 2015 11:04 am

Re: Compiling simgear on OSX Yosemite - stops at 97%

Postby bjax » Tue Apr 14, 2015 4:27 pm

Thanks, @Karam, for this very helpful information.

I'm not sure about the two compiler flags: "-g 03". Did you mean "-g -O3" (alpha O, not numeric 0)?

Also, is there a recommended location, relative to FlightGear, to assign to CMAKE_INSTALL_PREFIX?

-- Bruce
bjax
 
Posts: 1
Joined: Tue Apr 14, 2015 4:25 pm


Return to Compiling

Who is online

Users browsing this forum: No registered users and 1 guest