opencv - 无法识别的命令行选项 '-stdlib=libstdc++'

标签 opencv g++ libstdc++

我在 OS X 10.10.3 Yosemite 上遇到 g++ 编译器错误(编译 OpenCV 3.0 beta)。

g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin14/5.0.1/lto-wrapper
Target: x86_64-apple-darwin14
Configured with: /opt/local/var/macports/build/_opt_mports_dports_lang_gcc5/gcc5/work/gcc-5-20150421/configure --prefix=/opt/local --build=x86_64-apple-darwin14 --enable-languages=c,c++,objc,obj-c++,fortran,java --libdir=/opt/local/lib/gcc5 --includedir=/opt/local/include/gcc5 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-5 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-5 --with-gxx-include-dir=/opt/local/include/gcc5/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc5 5-20150421_0'
Thread model: posix
gcc version 5.0.1 20150421 (prerelease) (MacPorts gcc5 5-20150421_0) 

$ cd ~/opencv-3.0.0-beta/samples/cpp

$ g++ -ggdb `pkg-config --cflags --libs opencv` -stdlib=libstdc++ facedetect.cpp -o facedetect
g++: error: unrecognized command line option '-stdlib=libstdc++'

$ cd ~/opencv-3.0.0-beta/build
$ make
[  2%] Built target zlib
[  2%] Building CXX object 3rdparty/libtiff/CMakeFiles/libtiff.dir/tif_stream.cxx.o
c++: error: unrecognized command line option '-stdlib=libstdc++'
make[2]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/tif_stream.cxx.o] Error 1
make[1]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/all] Error 2

最佳答案

-stdlib=libstdc++ 是一个 Clang 选项,您不能将它与 GCC 一起使用。

关于opencv - 无法识别的命令行选项 '-stdlib=libstdc++',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30021058/

相关文章:

libstdc++ - 为什么不能交替使用 lib 的调试/发布版本

c++ - 我们在生成可执行文件时是否同时使用 libstdc++.a 和 libstdc++.so ?

c++ - 这是 std::gcd 中的错误吗?

opencv - EmguCV - 找不到 nvcuda.dll

opencv - 可视化点云

c++ - GCC 中 cmath 的 pow() 的正确性

C++:dll 不适用于 Visual Studio 2017,但适用于 g++

c++ - __attribute__ ((__packed__)) 对嵌套结构的影响是什么?

c++ - 链接 : fatal error LNK1104: cannot open file 'opencv_calib3d245d.lib' (OpenCV 2. 4.9)

visual-studio-2010 - 在opencv中用imshow显示max()函数的结果