我正尝试按照此 link 在我的 Mac 上安装 OpenCV
但是,当我在终端上键入 cmake -G "Unix Makefiles"..
时,会打印出此错误。
-- The CXX compiler identification is unknown -- The C compiler identification is unknown -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- broken CMake Error at /opt/local/share/cmake-3.0/Modules/CMakeTestCXXCompiler.cmake:54 (message): The C++ compiler "/usr/bin/c++" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/kwmaeng/Desktop/opencv/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec653545098/fast"
make: error: unable to find utility "make", not a developer tool or in PATH
CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:56 (project)
-- Configuring incomplete, errors occurred! See also "/Users/kwmaeng/Desktop/opencv/build/CMakeFiles/CMakeOutput.log". See also "/Users/kwmaeng/Desktop/opencv/build/CMakeFiles/CMakeError.log".
于是查看了CMakeError.log,内容是这样的
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /usr/bin/c++ Build flags: Id flags:
The output was: 72 xcodebuild: error: SDK "/Volumes/MAC/dev/adt-bundle-mac-x86_64-20131030/sdk" cannot be located. c++: error: unable to find utility "clang++", not a developer tool or in PATH ...(blah blah)
奇怪的是,/Volumes/MAC/dev/adt-bundle-mac-x86_64-20131030/sdk
是我安装Android SDK的地方,现在被删除了,所以有没有这样的文件夹了。发生错误是因为 cmake 指的是不再存在的无效路径吗?为什么 cmake 首先引用 android sdk 的位置?它对 opencv 有影响吗??
我在谷歌上搜索了几个小时,但没有找到太多帮助。如果您有任何想法,请帮助我。
提前致谢。
最佳答案
感谢大家的帮助,我得以解决我的问题。
对于将来可能遇到同样问题的其他人,这就是我所做的:
这是因为我的$PATH
被搞乱了(我想是在我尝试将Android SDK 添加到$PATH
时发生的)
我清除了 .bash_profile
并添加了 C++ 和 make 以及 /opt/local/bin
, /opt/local/sbin
像这样
export PATH=$PATH:/opt/local/bin:/opt/local/sbin:/usr/bin/c++:/usr/bin/make
而且效果很好。
关于c++ - "The C++ compiler "/usr/bin/c++ "is not able to compile a simple test program."尝试安装 OpenCV 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25976001/