Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 21, 2013, 09:42 AM   #1
printz
macrumors regular
 
Join Date: Dec 2012
Possible to release C++11 (+ library) applications for OSX 10.6?

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 by printz; May 31, 2013 at 07:54 AM.
printz is offline   0 Reply With Quote
Old May 23, 2013, 01:25 AM   #2
superriku11
macrumors member
 
Join Date: Jun 2012
Location: United States
Send a message via Skype™ to superriku11
Quote:
Originally Posted by printz View Post
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.
superriku11 is offline   0 Reply With Quote
Old May 24, 2013, 11:18 AM   #3
Cactus Dan
macrumors newbie
 
Join Date: Aug 2010
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
Cactus Dan is offline   0 Reply With Quote
Old May 25, 2013, 09:54 AM   #4
printz
Thread Starter
macrumors regular
 
Join Date: Dec 2012
It's not my code, so I don't have that level of control. All I do is port it to OSX.
printz is offline   0 Reply With Quote
Old May 26, 2013, 02:21 PM   #5
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
If you must have C++11 and 10.6 support, find a way to link the C++11 library statically to your app.
Madd the Sane is offline   0 Reply With Quote
Old May 26, 2013, 04:00 PM   #6
printz
Thread Starter
macrumors regular
 
Join Date: Dec 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?
printz is offline   0 Reply With Quote
Old May 26, 2013, 04:12 PM   #7
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by printz View Post
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.
chown33 is offline   0 Reply With Quote
Old May 26, 2013, 06:00 PM   #8
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: 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.
__________________
Get out of my mind, idea! I already have an idea in here!
Madd the Sane is offline   0 Reply With Quote
Old May 27, 2013, 10:09 AM   #9
printz
Thread Starter
macrumors regular
 
Join Date: Dec 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 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 by printz; May 27, 2013 at 10:21 AM.
printz is offline   0 Reply With Quote
Old May 31, 2013, 07:56 AM   #10
printz
Thread Starter
macrumors regular
 
Join Date: Dec 2012
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.
printz is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Remove unused applications from OSX MacPC OS X 10.8 Mountain Lion 18 Nov 22, 2013 05:32 PM
Any reason to backup the 'library' or 'applications' folders? DramaLLama OS X 8 Jul 14, 2013 04:48 PM
OSX 10.9 release is near? PBP OS X 4 Jun 6, 2013 07:41 PM
Old Applications/ folder (and current one) being used by Mountain Lion OSX xandrani OS X 1 Mar 10, 2013 02:30 PM
My Applications/Library/Audio folders are a mess. Where do I put all the files? stikygum Mac Basics and Help 0 Oct 5, 2012 11:29 AM

Forum Jump

All times are GMT -5. The time now is 08:45 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC