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

printz

macrumors regular
Original poster
Dec 23, 2012
216
0
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?
 
Last edited:

superriku11

macrumors member
Jun 16, 2012
58
0
United States
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?
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.
 

Cactus Dan

macrumors member
Aug 8, 2010
30
0
Howdy,

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.

Adios,
Cactus Dan
 

printz

macrumors regular
Original poster
Dec 23, 2012
216
0
It's not my code, so I don't have that level of control. All I do is port it to OSX.
 

printz

macrumors regular
Original poster
Dec 23, 2012
216
0
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?
 

chown33

Moderator
Staff member
Aug 9, 2009
8,495
4,503
Restivus
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?
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.
 

Madd the Sane

macrumors 6502a
Nov 8, 2010
508
40
Utah
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.
 

printz

macrumors regular
Original poster
Dec 23, 2012
216
0
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 http://libcxx.llvm.org/. 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.
 
Last edited:

printz

macrumors regular
Original poster
Dec 23, 2012
216
0
I managed to do it by downloading libc++ and libc++abi from libcxx.llvm.org and libcxxabi.llvm.org. I also needed clang from clang.llvm.org. 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.