无法识别的命令行选项'-stdlib = libc ++'与MacPorts gcc48 [英] Unrecognized Command Line Option '-stdlib=libc++' with MacPorts gcc48

查看:595
本文介绍了无法识别的命令行选项'-stdlib = libc ++'与MacPorts gcc48的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译包含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:无法识别的命令行选项'-stdlib = libc ++'

当我使用标志编译hello world程序时发生同样的问题: p>

  dhcp-130-112:helloworld bwells $ g ++ -stdlib = libc ++ helloworld.cpp 
g ++:error:无法识别的命令行选项'-stdlib = libc ++'

没有那个fl ag,它编译得很好:

  dhcp-130-112:helloworld bwells $ g ++ helloworld.cpp 
dhcp-130 -112:helloworld bwells $ ls
a.out helloworld.cpp

我的编译器版本是:

  dhcp-130-112:helloworld bwells $ g ++ --version 
g ++(MacPorts gcc48 4.8.2_2) 4.8.2
版权所有(C)2013自由软件基金会,Inc.
这是免费软件;请参阅复制条件的来源。没有任何b $ b保修;甚至不适用于适销性或针对特定用途的适用性。

运行结果 sudo port install gcc48 。我的Mac OS版本是10.9.3。代码文件helloworld.cpp就像你期望的那样:

  dhcp-130-112:helloworld为$ cat helloworld生效。 cpp 

#include< iostream>

int main(void)
{
std :: cout<< 你好,世界! <<的std :: ENDL;
返回0;
}
dhcp-130-112:helloworld bwells

问题:在互联网上可以收集的所有内容中,-stdlib = ...标志是g ++的标准部分。包含它时为什么会出现g ++错误?我怎样才能解决这个问题?



注意: b $ b虽然手动执行没有问题标志的setup.py行可以工作,并且允许完整的软件包进行编译,当我尝试将生成的软件包导入python时遇到链接错误。我担心这里的g ++问题是一个更大问题的症状,这就是为什么我试图直接解决它。

解决方案

> -stdlib = libc ++ 是一个Clang(不是GCC)选项,告诉clang使用LLVM libc ++标准库(这是Clang使用的),而不是GNU libstdc ++这是GCC使用的)。



因为你有链接错误,所以你使用的其他软件包可能是用clang和libc ++编译的,它不是ABI兼容的GCC的libstdc ++(除了一些低级别的东西)。所以你需要用clang和libc ++编译这个包。苹果公司的Xcode随附了clang(这可能是你想用的),而MacPorts也提供了一些clang发行版。


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:

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:

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

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?

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.

解决方案

-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).

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.

这篇关于无法识别的命令行选项'-stdlib = libc ++'与MacPorts gcc48的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆