0

Whenever I build simple C++ programs using Boost Python, I always have to manually go in and change the path to whichever boost libraries I executed the build with using the following command:

install_name_tool -change [old_boost_library_path] [new_boost_library_path] foo.cpp

Which prevents me from running into any Library not loaded: [boost_library] errors.

However, as you can imagine, it gets tedious having to go in and manually change the location of each incorrectly referenced boost library path (especially when dealing with several libraries).

So my question is. Is there any way to change the path of the boost libraries being used in the build during the build, so I don't have to do this after? As this would save me a lot of time and typing.

In my Makefile I have set a variable to include the needed libraries, similar to:

LD_LIBS=-L/boost_1_62_0/stage/lib -lboost_python3 -lboost_system -L/Library/Frameworks/Python.framework/Versions/3.5/lib -lpython3.5m

The output of running otool -L foo.cpp is:

Foo.cpp:
libboost_python3.dylib (compatibility version 0.0.0, current version 0.0.0)
libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
/Library/Frameworks/Python.framework/Versions/3.5/Python (compatibility version 3.5.0, current version 3.5.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

The path to the above boost libraries should be /boost_1_62_0/stage/lib/[library_name] not [library_name].

Is this fixable? Any help would be appreciated.

semore_1267
  • 1,327
  • 2
  • 14
  • 29

1 Answers1

0

Answer (for my particular case) found!

I just had to append the path of my boost libraries /boost_1_62_0/stage/lib to the $DYLD_LIBRARY_PATH variable in my .bash_profile.

More info about using DYLD_LIBRARY_PATH (and related path variables) in this SO question.

Hope this helps someone else.

Community
  • 1
  • 1
semore_1267
  • 1,327
  • 2
  • 14
  • 29
  • You're probably much better off using `-Wl,-rpath,/boost_1_62_0/stage/lib` in the compile command line. However, I'm pretty sure that if you built and installed boost into a particular non-stage location, it would have the relevant path name in the .dylib which would remove the need for the extra work. – Anya Shenanigans Nov 21 '16 at 23:00