Compiling against libc++ on 10.6 and using the binary on 10.7

Mojca Miklavec mojca at macports.org
Sat Mar 24 06:33:09 UTC 2018


On 24 March 2018 at 02:57, Ryan Schmidt wrote:
> On Mar 23, 2018, at 05:35, Mojca Miklavec wrote:
>
>> I'm compiling some command-line tools and I tried to aim supporting
>> 10.6 (asking 10.6 users to grab libc++ from somewhere if they are
>> desperate enough to want to use the binaries).
>>
>> I compiled against libc++ provided by MacPorts and asked a user to
>> test that binary on 10.7 (I would need to install one somewhere
>> first). Apparently the binaries did not work there, probably because
>> libc++ installed on 10.6 is newer than the one Apple shipped with
>> Lion. I need to double-check if that's in fact the case (he could have
>> mixed some binaries), but I just wanted to ask if there's some
>> workaround to that.
>
> I suppose that is a possible reason why it wouldn't work. Seeing the actual error message might help diagnose.

$ ./foo --version
dyld: Symbol not found: __ZNSt12length_errorD1Ev
  Referenced from: /path/to/./foo
  Expected in: /usr/lib/libc++abi.dylib
 in /path/to/./foo
Trace/BPT trap: 5

>> (Maybe I should then compile on Lion, grab the 10.6 SDK from
>> somewhere, compile against 10.6 SDK and link against libc++ from Lion?
>> I don't particularly like this idea though. I could use the "cxx11
>> 1.1" trick, but I hate to have to relink all the binaries at the end.
>> None of that is ideal.)
>
> Do you really need the 10.6 SDK? You're supposed to be able to use the latest SDK, and set MACOSX_DEPLOYMENT_TARGET to the lowest OS version you want to run on.

I don't know. I clearly remember that long long time ago I would
compile on 10.6 with MACOSX_DEPLOYMENT_TARGET set to 10.5, but until I
added the -isysroot the binaries would not work on 10.5. Usually
autotools figure out that they could use a function that exists in
that newer SDK and then the binary no longer works. If I compile
against 10.7: would you do it on a 10.6 or a 10.7 VM? If I compile
against the 10.7 SDK I would indeed get that older libc++ library that
should then hopefully work everywhere.

Mojca


More information about the macports-dev mailing list