"C ++ compiler" / usr / bin / C ++ "cannot compile a simple test program." When trying to install OpenCV

I am trying to install OpenCV on my Mac by following this link

However, when I type cmake -G "Unix Makefiles" .. on my terminal, this error is printed.

- CXX compiler identifier unknown - C compiler identifier unknown - Check CXX compiler operation: / usr / bin / C ++ - Check CXX compiler operation: / usr / bin / C ++ - broken CMake error in / opt / local / share / cmake -3.0 / Modules / CMakeTestCXXCompiler.cmake: 54 (message): C ++ compiler "/ usr / bin / C ++" cannot compile a simple test program.

The following output failed:

Edit Dir: / Users / kwmaeng / Desktop / opencv / build / CMakeFiles / CMakeTmp

Run the build command: "/ usr / bin / make" "cmTryCompileExec653545098 / fast"

make: error: cannot find the "make" utility, not the developer tool or in PATH

CMake will not be able to generate this project correctly. Call Stack (last call first): CMakeLists.txt: 56 (project)

- Configuring incomplete, errors have occurred! See also "/Users/kwmaeng/Desktop/opencv/build/CMakeFiles/CMakeOutput.log". See also "/Users/kwmaeng/Desktop/opencv/build/CMakeFiles/CMakeError.log".

So, I checked CMakeError.log and this content

Compilation of CXX Msgstr compiler identification source file "CMakeCXXCompilerId.cpp Error". Compiler: / usr / bin / C ++ Assembly lines: Identification flags:

Output: 72 xcodebuild: error: SDK "/ Volumes / MAC / dev / adt-bundle-mac-x86_64-20131030 / sdk" cannot be located. C ++: error: could not find the "clang ++" utility, not the developer tool or in PATH ... (blah blah)

Strange, /Volumes/MAC/dev/adt-bundle-mac-x86_64-20131030/sdk is where my Android SDK was installed and now it is deleted, so there is no such folder anymore. Is there an error because cmake refers to an invalid path that no longer exists? Why does cmake refer to android sdk location in the first place? Does it even matter for opencv ??

I googled for hours, but not much was found. Please help me if you have any ideas.

Thanks in advance.

+7
c ++ xcode opencv macos
source share
6 answers

Thanks to everyone, I managed to solve my problem.

For other people who may suffer from the same problem in the future, this is what I did:

this happened because my $PATH was corrupted (I think this happened when I tried to add the Android SDK to $PATH )

I cleared .bash_profile and added C ++ and make and /opt/local/bin , /opt/local/sbin

like this

 export PATH=$PATH:/opt/local/bin:/opt/local/sbin:/usr/bin/c++:/usr/bin/make 

and he worked like a charm.

+2
source share

I had the same problem: worked with command line tools:

 rm -rf /Library/Developer/CommandLineTools 

Then reinstall the command line tool:

 xcode-select --install 

Who knows what this script does ... and I don't have time to investigate, so you go ...

+2
source share

I also came across this problem, I fixed it by installing the correct CXXFLAGS and CPPFLAGS. I think you should also check this out.

One simple solution:

CPPFLAGS := $(CPPFLAGS) $(CFLAGS) CXXFLAGS := $(CXXFLAGS) $(CFLAGS)

0
source share

For me, the first problem was that I did not have Xcode command line tools. I got those ( xcode-select --install in terminal) and I still had the problem. Decision? Close the terminal window and create a new one. Then, voila!

0
source share

I found another solution: putting set(CMAKE_C_COMPILER gcc) at the very top of my CMakeLists.txt . For reference, I received this error immediately after installing the CLION update.

Here is my last CMakeLists.txt :

 set(CMAKE_C_COMPILER gcc) cmake_minimum_required(VERSION 3.6) project(...) set(CMAKE_CXX_STANDARD 11) set(SOURCE_FILES XXX.cpp) add_executable(... ${SOURCE_FILES}) 
0
source share

I also experienced this problem and solved it.

The code:

 yum -y install gcc-c++ 
-2
source share

All Articles