c++ - "The C++ compiler "/usr/bin/c++ "is not able to compile a simple test program."尝试安装 OpenCV 时

标签 c++ xcode macos opencv

我正尝试按照此 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/

相关文章:

ios - 从本地下载 url 图像和 uitableview 单元格图像并在 iOS 中并行执行。如何实现?

swift - 展开 Segue 导航栏按钮 Xcode 8.0 Swift 3.0

xcode - 在可设置的下标上进行类型删除会产生奇怪的错误;这是编译器错误还是我做错了什么?

c - 为什么 popen() 只工作一次?

python - 从命令行或 pkg 中的可执行文件运行时,Py2app 构建可以完美运行,但双击应用程序时则无法运行

ios - 不断打开 OS X 和 iOS 之间的 BLE 连接

c++ - 在 .cpp 或 .h 中包含头文件的最佳方法是什么?

c++ - Visual Studio 上的 C

c++ - 在 C++ 中为矩阵的第一行赋值

c++ - 处理派生类指针 vector 的正确方法?