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

℡╲_俬逩灬. 提交于 2019-12-18 04:54:09

问题


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


回答1:


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.




回答2:


One way to accomplish this appears to be to build opencv from source, and use the configure.cxx_stdlib variable to specify libstdc++ as your C++ runtime.

Try out the following:

sudo port install -s opencv configure.cxx_stdlib="libstdc++"


来源:https://stackoverflow.com/questions/21546810/macports-on-osx-10-9-compile-with-stdlib-libstdc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!