2015-05-04 54 views
2

我在OS X 10.10.3 Yosemite上遇到g ++编译器错误(编译OpenCV 3.0 beta)。无法识别的命令行选项'-stdlib = libstdC++'

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 
+0

改为使用Clang:'export CC = clang'。 – jww

+0

$ CC = clang CXX = clang ++ cmake -DCMAKE_INSTALL_PREFIX =/usr/local -Wno-dev -DNVCC_FLAGS_EXTRA =“ - Xcompiler -stdlib = libstdC++; -Xlinker -stdlib = libstdC++”-DOPENCV_EXTRA_CXX_FLAGS =“ - stdlib = libstdC++”-DOPENCV_EXTRA_EXE_LINKER_FLAGS = “-stdlib = libstdC++”.. – dbl001

+0

仍然不正确... - C/C++: - 构建为动态库?:是 - C++编译器:/ opt/local/bin/C++(ver 4.8.4 ) - C++ flags(Release):-stdlib = libstdC++ -O3 -DNDEBUG -DNDEBUG - C++ flags(Debug):-stdlib = libstdC++ -g -O0 -DDEBUG -D_DEBUG - C编译器:/ opt /本地/ bin/gcc - C标志(发布):-fsigned-char -W -Wall -Werror =返回类型 - – dbl001

回答

1

-stdlib=libstdc++是一个Clang选项,你不能在GCC中使用它。

相关问题