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

Mojca Miklavec mojca at macports.org
Sat Mar 31 16:30:49 UTC 2018


On 24 March 2018 at 12:40, Ryan Schmidt wrote:
> On Mar 24, 2018, at 01:33, Mojca Miklavec wrote:
>> 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.
/.../
>>>> (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.
>
> I guess Apple's instructions to use the latest SDK only apply to Mac-specific software that has been written to understand the SDK situation, and autotools-based projects might not understand it.
>
> I guess then you should compile on any OS version, 10.6 or later, setting MACOSX_DEPLOYMENT_TARGET to 10.6 and using the 10.6 SDK from Xcode 3.2-4.3.3, with 10.7's libc++ copied into it.

I did another experiment now. I built everything on 10.6 with
    -isysroot /Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.6

Most of the binaries (those which failed earlier and use C++11
libraries like poppler etc.) now work on both 10.6 and 10.7 (well, at
least ./foo --version seems to work), except that I now ended up with
*other* binaries failing to work on 10.6 (that is: on the exact same
machine where I built them) due to X11 linking problems:

./mf -version
dyld: Library not loaded: /usr/X11/lib/libX11.6.dylib
  Referenced from: /path/to/./mf
  Reason: Incompatible library version: mf requires version 10.0.0 or
later, but libX11.6.dylib provides version 9.0.0
Trace/BPT trap

I guess that using a "custom-made" SDK (10.6 SDK with libc++ borrowed
from Lion) is indeed the only option.

Mojca


More information about the macports-dev mailing list