I'm compiling some source code that requires some dylibs from other project that I have already built. I'm getting
ld: symbol(s) not found for architecture x86_64`
Whenever I execute
g++ some_code.cpp -I/usr/local/include -o executable_binary
I know that g++
is not able to find the compiled the dylibs (installed at /usr/local/include
) since the error also mentions a lot of specific symbols that are part of the dylibs.
I have already tried this:
- Executing
install_name_tool -id "@/usr/local/lib/requiredlib.dylib" /usr/local/lib/requiredlib.dylib
- Adding
-L/usr/local/lib
to the compilation options. - Adding all the dylib paths explicitly to the compilation options.
- Try to add
DYLD_LIBRARY_PATH
unsuccessfully since Sierra doesn't allow to set that variable for security reasons.
I know that it might possible to add DYLD_LIBRARY_PATH
but that requires to disable SIP. I can do it by I do not want to if there is a cleaner way to do this.
P.S.: I am trying to compile the tutorial examples for Tulip graph library.
The missing symbols are related to the the graph library I have installed. The error message is:
Undefined symbols for architecture x86_64:
"tlp::saveGraph(tlp::Graph*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, tlp::PluginProgress*)", referenced from:
_main in tutorial001-02ee7e.o
"operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, tlp::Graph const*)", referenced from:
_main in tutorial001-02ee7e.o
ld: symbol(s) not found for architecture x86_64
Whenever I do ls /usr/local/lib/requiredlib.dylib
the all the compiled libraries from Tulip are there.
g++ -v
produces:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
After doing ls /usr/local/include/tulip/
I get the list of *.h
files of the libraries I intend to use.