Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Macports on OSX 10.9 - compile with -stdlib=libstdc++

In OSX 10.9 the default -stdlib option for clang++ is libc++, so that's what Macport uses when building packages. Is there any way to tell Macports to use libstdc++ instead?

In particular I would like to build OpenCV through Macports so it's using libstdc++, but I imagine I'll run into a need to do so for other packages as well

like image 364
Puchatek Avatar asked Feb 04 '14 07:02

Puchatek


People also ask

How do I know if MacPorts is installed on my Mac?

Get the MacPorts base here: http://www.macports.org. Click on the DOWNLOAD link and grab the . dmg disk image for whichever OS you may have. Confirm that MacPorts is installed by typing "which port" and verifying that it returns /opt/local/bin/port.

What is MacPorts user Mac?

MacPorts, formerly called DarwinPorts, is a package management system that simplifies the installation of software on the macOS and Darwin operating systems. It is an open-source software project that aims to simplify the installation of other open source software.


1 Answers

The option is simply: -stdlib=libstdc++

If you need finer control over the build process for various ports, you can always set variables like:
CXX = "clang -std=c++11 -stdlib=libc++, CXXFLAGS = "-Wall -O2 -march=core2", etc.

And build <port> from source:

sudo port -s install <port> -universal \
configure.cc="${CC}" configure.cxx="${CXX}" \
configure.cflags="${CFLAGS}" configure.cxxflags="${CXXFLAGS}"

The other alternative, is to install the gcc48 (or above) port, and use it as the compiler. Don't use the old gcc-4.2.1 installed with older versions of Xcode. It's rubbish.

like image 98
Brett Hale Avatar answered Oct 31 '22 04:10

Brett Hale