Resolved Possible to release C++11 (+ library) applications for OSX 10.6?

Discussion in 'Mac Programming' started by printz, May 21, 2013.

  1. printz, May 21, 2013
    Last edited: May 31, 2013

    printz macrumors regular

    Dec 23, 2012
    If I'm in Xcode 4 and set the compiler to use the C++11 standard libraries, I get a warning that my program will only work on OSX 10.7 and later.

    On OSX 10.6, I'm able to install GCC 4.8, via MacPorts, to get C++11 support, complete with its associated libstdc++. I can build such programs from a Makefile. But are such programs portable, or do they require MacPorts and GCC 4.8 installed on user's computers? I wonder if I can package libstdc++ (as installed by MacPorts) with my program, inside the app bundle. Any idea which file I should take? There are several libstdc++ dylib files in my /opt/local/lib folder, am I supposed to bundle one of them?
  2. superriku11 macrumors member


    Jun 16, 2012
    United States
    C++ compiles to regular machine code so presumably it should work. It may rely on libraries put in place by your MacPorts installation(s) however, so the only way to know is to try.
  3. Cactus Dan macrumors member

    Aug 8, 2010

    Do you absolutely need C++11? I mean if you're worried about backward compatibility can you still make it work by doing your development in 10.6?

    Or, can you create wrapper function calls that check for the Mac OSX version, and within the wrapper function make the appropriate call to the C++ functions?

    Or, can you just compile separate versions, using preprocessor defines to determine which Mac OS you're compiling and have both the 10.7 code and the 10.6 code in the same source?

    That last method I use quite frequently to keep my Cinema 4D plugins backward compatible with many versions of the application's API.

    Cactus Dan
  4. printz thread starter macrumors regular

    Dec 23, 2012
    It's not my code, so I don't have that level of control. All I do is port it to OSX.
  5. Madd the Sane macrumors 6502a

    Madd the Sane

    Nov 8, 2010
    If you must have C++11 and 10.6 support, find a way to link the C++11 library statically to your app.
  6. printz thread starter macrumors regular

    Dec 23, 2012
    And which is that? libc++? libstdc++? libc++abi?

    Can I use that Terminal command whose name escapes me now (it has two letters IIRC) that lists the dependencies of the executable?
  7. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    otool ? nm ?

    You should read their man pages to find out which one. Then try them on your executable, with various options as available, and see what you get. I suspect 'otool -L' will be the most revealing.

    If 'otool -L' tells you what you need to know, then here's a thread about changing the install-name of dylibs.
  8. Madd the Sane macrumors 6502a

    Madd the Sane

    Nov 8, 2010
    You most likely will have to build the C++11 library as a static and then link to it.

    You most likely will be using a version of GCC, so the library would be libstdc++. I don't know if Clang's libc++ will build on 10.6, because I don't know if the dependent libc++abi will build.
  9. printz, May 27, 2013
    Last edited: May 27, 2013

    printz thread starter macrumors regular

    Dec 23, 2012
    Looks like I can download Clang binary from its website. I can also download libc++ and libc++abi from MacPorts.

    Looking over the Internet, a common suggestion on this issue was to supply libc++ and libc++abi with my program.

    I wonder: how do I tell the independent (non-Apple) Clang to link with a portable (relative to executable directory) libc++?
    EDIT: Found this too It has both libc++ and how to use it instead of system's… Now to find out how to make it either statically linked, or portable.

    Currently MacPorts is downloading and compiling libc++ and libc++abi. I wonder if it will also create .a files.

    Big problem is that I just cannot expect users to wait hours for something to install, as it is via MacPorts/Homebrew/Fink in general.
  10. printz thread starter macrumors regular

    Dec 23, 2012
    I managed to do it by downloading libc++ and libc++abi from and I also needed clang from On the libraries, I edited the buildit scripts to produce dylibs whose install_name are @loader_path/<lib name> (where you substitute <lib name> for the file name). I had to build libc++abi first, this way, then libc++. I also had to make sure everything uses the downloaded clang compiler, not the OSX built-in one.

Share This Page