Using boost on MacOS with MacPorts

137 Views Asked by At

I'm trying to build some software on MacOS that uses boost (specifically boost_system). It all appears to configure and build ok, but when it goes to link it gives the error:

ld: library 'boost_system' not found

Looking at the boost libraries that MacPorts installed, they all appear to have a -mt suffix -- I find /opt/local/lib/libboost_system-mt.dylib. If I change the Makefile.am file to use -lboost_system-mt instead, then everything works, but of course that is both very painful and would break any other build.

Anyone know what is going on here? Where does this -mt suffix come from? Is this a problem with MacPorts or something else?

1

There are 1 best solutions below

2
VonC On BEST ANSWER

The -mt suffix in your Boost library filenames stands for "multithreaded" (as illustrated in this thread). That naming convention is used by some package managers, including MacPorts, to distinguish between single-threaded and multithreaded versions of the Boost libraries.

First option: Instead of editing Makefile.am directly, you might be able to pass the correct library name to your build configuration script. That is often done via flags like LDFLAGS or LIBS.

LDFLAGS="-lboost_system-mt" ./configure

Or: create a symlink from libboost_system.dylib to libboost_system-mt.dylib. That way, your software can link against libboost_system while actually using the multithreaded variant.

ln -s /opt/local/lib/libboost_system-mt.dylib /opt/local/lib/libboost_system.dylib