I'm writing a dylib in C++, but when I try to link it into my application, it gives me an error on execution:
dyld: lazy symbol binding failed: Symbol not found: __ZN8Vector2DC1Ev
Referenced from: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/Singularity Test App
Expected in: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/libSingularity.dylib
dyld: Symbol not found: __ZN8Vector2DC1Ev
Referenced from: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/Singularity Test App
Expected in: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/libSingularity.dylib
I made sure the symbol wasn't stripped, and
nm -g libSingularity.dylib | grep "T" | grep __ZN8Vector
reports that the symbol is present in the library:
0000000000006df6 T __ZN8Vector2DC1Eff
0000000000006d98 T __ZN8Vector2DC1Ev
0000000000006dc2 T __ZN8Vector2DC2Eff
0000000000006d6e T __ZN8Vector2DC2Ev
I'm linking from inside XCode, so the link commands are kind of weird. Here's the linker command for the dylib:
Ld "/Users/noahz/Desktop/Singularity/Singularity Engine/build/Debug
/libSingularity.dylib" normal x86_64
cd "/Users/noahz/Desktop/Singularity/Singularity Engine"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/g++-4.2 -arch x86_64 -dynamiclib -isysroot /Develope
/SDKs/MacOSX10.6.sdk "-L/Users/noahz/Desktop/Singularity/Singularity Engine/build
/Debug" "-F/Users/noahz/Desktop/Singularity/Singularity Engine/build/Debug"
-filelist "/Users/noahz/Desktop/Singularity/Singularity Engine/build/Singularity
Engine.build/Debug/Singularity Engine.build/Objects-normal/x86_64
/libSingularity.LinkFileList" -install_name libSingularity.dylib -mmacosx-version-
min=10.6 -framework sfml-system-d -framework sfml-window-d -framework SFML
-framework OpenGL -framework OpenAL -framework sfml-graphics-d -single_module
-compatibility_version 1 -current_version 1 -o "/Users/noahz/Desktop/Singularity
/Singularity Engine/build/Debug/libSingularity.dylib"
and here's the linker command for the test app:
cd "/Users/noahz/Desktop/Singularity/Singularity Test App"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/g++-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk
"-L/Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug" "-F/Users
/noahz/Desktop/Singularity/Singularity Test App/build/Debug" -filelist "/Users/noahz
/Desktop/Singularity/Singularity Test App/build/Singularity Test App.build/Debug
/Singularity Test App.build/Objects-normal/x86_64/Singularity Test
App.LinkFileList" -mmacosx-version-min=10.6 "/Users/noahz/Desktop/Singularity
/Singularity Engine/build/Debug/libSingularity.dylib" -o "/Users/noahz/Desktop
/Singularity/Singularity Test App/build/Debug/Singularity Test App"
Any ideas on why this is happening and/or how to fix it?