Skip to main content
Up and Coming
April 27, 2013

[OSX] Problem building sample app from command line

Hi folks

So I'm having a linking issue when building my small sample app from the command line on OSX:

Here is the small version:

$ c++ -I./OculusSDK/LibOVR/Include -L./OculusSDK/LibOVR/Lib/MacOS/Debug/ -lovr -framework CoreFoundation -framework IOKit -framework CoreGraphics test.cpp
Undefined symbols for architecture x86_64:
"typeinfo for OVR::Allocator", referenced from:
typeinfo for OVR::Allocator_SingletonSupport<OVR::DefaultAllocator> in test-j198Gt.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Here is with -v:

$ c++ -v -I./OculusSDK/LibOVR/Include -L./OculusSDK/LibOVR/Lib/MacOS/Debug/ -lovr -framework CoreFoundation -framework IOKit -framework CoreGraphics test.cpp ⏎
Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 133.3 -v -resource-dir /usr/bin/../lib/clang/4.0 -I ./OculusSDK/LibOVR/Include -fmodule-cache-path /var/folders/gw/bsr2j9k917bffjfd4_fvlk100000gn/T/clang-module-cache -fdeprecated-macro -fdebug-compilation-dir /Users/steeve/projects/oculus -ferror-limit 19 -fmessage-length 179 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/gw/bsr2j9k917bffjfd4_fvlk100000gn/T/test-cXjbn4.o -x c++ test.cpp
clang -cc1 version 4.0 based upon LLVM 3.1svn default target x86_64-apple-darwin12.3.0
ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64"
ignoring nonexistent directory "/usr/include/c++/4.0.0"
ignoring nonexistent directory "/usr/include/c++/4.0.0/i686-apple-darwin8/"
ignoring nonexistent directory "/usr/include/c++/4.0.0/backward"
#include "..." search starts here:
#include <...> search starts here:
./OculusSDK/LibOVR/Include
/usr/include/c++/4.2.1
/usr/include/c++/4.2.1/backward
/usr/local/include
/usr/bin/../lib/clang/4.0/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o a.out -L./OculusSDK/LibOVR/Lib/MacOS/Debug/ -lovr -framework CoreFoundation -framework IOKit -framework CoreGraphics /var/folders/gw/bsr2j9k917bffjfd4_fvlk100000gn/T/test-cXjbn4.o -lstdc++ -lSystem /usr/bin/../lib/clang/4.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"typeinfo for OVR::Allocator", referenced from:
typeinfo for OVR::Allocator_SingletonSupport<OVR::DefaultAllocator> in test-cXjbn4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Anybody got this error before?

    5 replies

    Up and Coming
    April 27, 2013
    I had the same problem here https://developer.oculusvr.com/forums/viewtopic.php?f=20&t=655. You can fix it by either rebuilding the Oculus SDK libovr.a to enable C++ RTTI and Exceptions, or you can change your project to not depend on RTTI or Exceptions. Either one works, I finally decided on the former as some of the stuff I'm linking against requires that support. I haven't found any negative performance issues due to this, but I could be wrong.

    This might be one of the flags causing your problems:
    -fcxx-exceptions -fexceptions
    Ibex 3D VR Desktop for the Oculus Rift: http://hwahba.com/ibex - https://bitbucket.org/druidsbane/ibex
    steeveAuthor
    Up and Coming
    April 27, 2013
    Awesome! Didn't see your post!
    Rebuilding libovr with RTTI indeed solved the linking issue!

    Thanks!
    steeveAuthor
    Up and Coming
    April 27, 2013
    Update, you can also get away without rebuilding libOVR by adding -fno-rtti.

    Eg mine:

    $ c++ -I./OculusSDK/LibOVR/Include -L./OculusSDK/LibOVR/Lib/MacOS/Debug -lovr -framework CoreFoundation -framework IOKit -framework CoreGraphics -fno-rtti test.cpp
    Participant
    August 7, 2013
    "steeve" wrote:
    Awesome! Didn't see your post!
    Rebuilding libovr with RTTI indeed solved the linking issue!

    Thanks!


    I have the same prob. How do I rebuild libovr with RTTI?
    New Participant
    August 7, 2013
    "Frim" wrote:
    How do I rebuild libovr with RTTI?

    By setting "Enable C++ Runtime Types" to Yes. If you build from the command line, you can do that by passing GCC_ENABLE_CPP_RTTI=Yes, eg like this:

    $ xcrun xcodebuild -target ovr -configuration Release GCC_ENABLE_CPP_RTTI=YES


    If you use Xcode, select the ovr target, go to the build settings and just type "rtti" in the search field.
    Lead Idiot