Context
上下文
I'm trying to compile the package "root_numpy" which is a link between the scientific analysis software "root" and the python package "numpy". It's used as part of the root wrapper "rootpy". I get a g++ error when the following line is executed:
我正在尝试编译包“root_numpy”,它是科学分析软件“root”和python包“numpy”之间的链接。它被用作根包装器“rootpy”的一部分。当执行下面一行时,我得到一个g++错误:
g++ -bundle -undefined dynamic_lookup -g -arch x86_64 -headerpad_max_install_names
-arch x86_64 build/temp.macosx-10.6-x86_64-2.7/root_numpy/src/_librootnumpy.o
-o build/lib.macosx-10.6-x86_64-2.7/root_numpy/_librootnumpy.so
-L/Users/bwells/bin/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d
-lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread
-lpthread -Wl,-rpath,/Users/bwells/bin/root/lib -stdlib=libc++ -lm -ldl
-lTreePlayer
g++: error: unrecognized command line option '-stdlib=libc++'
The same problem occurs when I compile a "hello world" program with the flag:
当我用国旗编译一个“hello world”程序时,也会出现同样的问题:
dhcp-130-112:helloworld bwells$ g++ -stdlib=libc++ helloworld.cpp
g++: error: unrecognized command line option '-stdlib=libc++'
Without that flag, it compiles fine:
如果没有这个标志,它就可以编译:
dhcp-130-112:helloworld bwells$ g++ helloworld.cpp
dhcp-130-112:helloworld bwells$ ls
a.out helloworld.cpp
My compiler version is:
我的编译器版本是:
dhcp-130-112:helloworld bwells$ g++ --version
g++ (MacPorts gcc48 4.8.2_2) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AKA the result of running sudo port install gcc48
. My Mac OS version is 10.9.3. The code file "helloworld.cpp" is as you'd expect
也就是运行sudo端口安装gcc48的结果。我的Mac OS版本是10.9.3。代码文件”helloworld。正如你所期望的那样。
dhcp-130-112:helloworld bwells$ cat helloworld.cpp
#include <iostream>
int main(void)
{
std::cout << "Hello world!" << std::endl;
return 0;
}
dhcp-130-112:helloworld bwells$
Question: From everything I can gather on the internet, the "-stdlib=..." flag is a standard part of g++. Why do I get a g++ error when including it? How can I fix this?
问:从我能在互联网上收集到的所有信息来看,“-stdlib=…”标志是g++的标准部分。为什么在包括它的时候会出现一个g++错误?我怎么解决这个问题?
Note: While manually executing the setup.py line without the problem flag works, and allows the full package to compile, I experience linking errors when I try to import the resulting package into python. I'm concerned that the g++ problem here is a symptom of a larger issue, which is why I'm trying to solve it directly.
注意:在手动执行设置时。没有问题标志的py行,并且允许完整的包进行编译,当我尝试将结果包导入python时,我体验到链接错误。我担心这里的g++问题是一个更大问题的症状,这就是我为什么要直接解决它的原因。
1 个解决方案
#1
10
-stdlib=libc++
is a Clang (not GCC) option and tells clang to use LLVM libc++ standard library (which is what Clang uses) rather than GNU libstdc++ (which is what GCC uses).
-stdlib=libc++是一个Clang(不是GCC)选项,并告诉Clang使用LLVM libc++标准库(这是Clang使用的),而不是GNU libstdc++(这是GCC所使用的)。
Since you got linking errors, it seems likely that other packages you are using were compiled with clang and libc++, which is not ABI compatible with GCC's libstdc++ (except for some low-level stuff). So you'll need to compile the package with clang and libc++ as well. Apple's Xcode comes with clang (which is probably what you'd want to use for this), and MacPorts also supplies a number of clang distributions.
因为您有链接错误,所以您使用的其他包很可能是用clang和libc++编译的,这与GCC的libstdc++(除了一些低级别的东西)是不兼容的。因此,您需要使用clang和libc++来编译包。苹果的Xcode附带了clang(这可能是你想要使用的),MacPorts也提供了一些clang发行版。
#1
10
-stdlib=libc++
is a Clang (not GCC) option and tells clang to use LLVM libc++ standard library (which is what Clang uses) rather than GNU libstdc++ (which is what GCC uses).
-stdlib=libc++是一个Clang(不是GCC)选项,并告诉Clang使用LLVM libc++标准库(这是Clang使用的),而不是GNU libstdc++(这是GCC所使用的)。
Since you got linking errors, it seems likely that other packages you are using were compiled with clang and libc++, which is not ABI compatible with GCC's libstdc++ (except for some low-level stuff). So you'll need to compile the package with clang and libc++ as well. Apple's Xcode comes with clang (which is probably what you'd want to use for this), and MacPorts also supplies a number of clang distributions.
因为您有链接错误,所以您使用的其他包很可能是用clang和libc++编译的,这与GCC的libstdc++(除了一些低级别的东西)是不兼容的。因此,您需要使用clang和libc++来编译包。苹果的Xcode附带了clang(这可能是你想要使用的),MacPorts也提供了一些clang发行版。