Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] unable to link on OS X when MACOSX_DEPLOYMENT_TARGET=10.7
From: Robert Ramey (ramey_at_[hidden])
Date: 2017-06-26 19:55:21


On 6/26/17 12:36 PM, Pavol Juhas via Boost-users wrote:
> Hello,
>
> I'd like to build the boost_serialization library with a compatibility setup
> for Mac OS X version 10.7, because I need to use it with Anaconda Python
> binaries, which are built for OS X 10.7. The OS X compatibility version can be
> set either by passing `-mmacosx-version-min=10.7` as a compile and link option
> or by setting environment variable MACOSX_DEPLOYMENT_TARGET=10.7.
>
> If I do so, the boost_serialization library builds without complaints,
> however I am not able to link it with my test program. Here are the steps
> I take to compile boost_serialization and the test program starting from
> a fresh boost 1.64.0 tree:
>
> # --------------------------------------------------------------
>
> $ export MACOSX_DEPLOYMENT_TARGET=10.7
> $ ./bootstrap.sh
> $ ./b2 -j4 variant=release link=shared --with-serialization stage
>
> # The stage/lib directory now contains libboost_serialization.dylib.
> # Use it to build a test program from tarchive.cpp:
>
> $ c++ tarchive.cpp -I. -Lstage/lib -lboost_serialization
> Undefined symbols for architecture x86_64:
> "boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive,
> char, std::char_traits<char> >::init()", referenced from:
> boost::archive::binary_oarchive_impl<boost::archive::binary_oarchive,
> char, std::char_traits<char> >::init(unsigned int) in
> tarchive-5e24a9.o
> "boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive,
> char, std::char_traits<char> >::save(std::string const&)", referenced
> from:
> void boost::archive::save_access::save_primitive<boost::archive::binary_oarchive,
> std::string>(boost::archive::binary_oarchive&, std::string const&) in
> tarchive-5e24a9.o
> ...
>
> # --------------------------------------------------------------
>
> The only thing the test program (attached) does is to instantiate the
> boost::archive::binary_oarchive class. The procedure above works
> fine when MACOSX_DEPLOYMENT_TARGET is set to 10.9 or higher.
>
> Am I missing some option that would fix the failed linking when
> building for OS X 10.7? I suppose this could be related to object
> visibility options as the serialization library is compiled with
> "-fvisibility=hidden" and "-fvisibility-inlines-hidden" options.

I'm sorry I can't help much. I do you mac os. I build and test the
serialization library with xcode project generated by CMake. The xcode
(and by extension Clang C++) has a huge number of options any one of
which could be the reason that one can't link two modules. Note that I
also test with the bjam command line which also has access to
compile/link time switches. I test this with both gcc and clang

I would suggest:

a) Make sure you can build/test without the
MACOSX_DEPLOYMENT_TARGET=10.7 setting. If this is indeed the problem
you this would help you know.

b) try b2 build and try CMake build

Once you get one of these to work, add in the MACOSX_DEPLOYMENT_TARGET
and try again.

Basically this is trial and error to find what the magic "global
variable" has to be set to make things work. Unfortunately, we have to
do a lot of this these days - it's a fact of life.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net