Reputation: 21
I want to link some dynamic libraries in my project with scons.
Example:
source/main.cpp
tool/lib/libboost_system.dylib
Binary Location
source/progbinary
My problem is, after the link process, the binary can't find libboost_system.dylib
dyld: Library not loaded: libboost_system.dylib
otool -L
shows the problem. I can fix this with a little script that corrects the path. But I want to do this in scons.
On linux it is really easy I have only to set the RPATH
in scons.
----- after the tip from @Brady
I add Linkflags for my library. After Linking I got the Error
'g++: error: -install_name only allowed with -dynamiclib'
So I add to the command
LINKFLAGS = '-dynamiclib install_name @executable_path/libWhatever.dylib'
And now I get if I call my execute the message
'cannot execute binary file'
And
otool -L
show me:
@executable_path/tools/lib/libboost_filesystem.dylib (compatibility version 0.0.0, current version 0.0.0) libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
the linking command from scons looks like:
/opt/local/bin/g++ -o source/prog -dynamiclib -install_name @executable_path/tools/lib/libboost_system.dylib source/main.o -Ltools/lib -lboost_system
Upvotes: 2
Views: 1308
Reputation: 10357
According to the comment provided above by trojanfoe: scons dylib dynamic linking on mac
The following needs to be passed to the linker:
-install_name @executable_path/libWhatever.dylib
This can be done in SCons as follows:
env = Environment()
env.Append(LINKFLAGS = ['-install_name @executable_path/libWhatever.dylib'])
If you need to compile a dynamic (shared) library, it can be done with the SharedLibrary() builder.
Upvotes: 2