2

I have gcc and g++ correctly set. However, when I try to install OpenCV, it gives me this error -

g++: error: /Users/vgokhale/Desktop/opencv-2.4.5/modules/highgui/src/window_cocoa.mm: Objective-C++ compiler not installed on this system

I am not sure how to set the Objective-C++ compiler. I thought this would be g++? Searching google doesn't return much. This seems to be a very rare error. Why does this occur?

maverick1989
  • 342
  • 7
  • 20
  • 1
    I'm sorry but if someone can respond with why it was wrong of me to post this, that would help me more than simply voting the question down. This way I might repeat my mistake again. – maverick1989 Jun 10 '13 at 20:36
  • Have you tried to do a simpler test by running a plain template project (the Single View Application or any other) and renaming any .m file to .mm? If there is a problem with your compiler, this may also fail. – Ricard Pérez del Campo Jun 10 '13 at 21:22
  • Yes. Any time I try to compile a .mm file (.m works), I get the same error. Should I pass the objective-c++ flag to the compiler? I have seen this solution all over the internet, but I am not sure how to do that at command line. This problem mainly comes up when using xcode. – maverick1989 Jun 11 '13 at 15:20

2 Answers2

0

The compiler should already work without having to tweak it. All you have to do is name your Objective-C files with a .mm extension (rather than .m) and you should be good to go. Check this link for more info on it: What is Objective C++?

Community
  • 1
  • 1
Henry F
  • 4,960
  • 11
  • 55
  • 98
  • 1
    The file already has a ".mm" extension. I found your solution several times but that is to a question that asks for how to compile using objective-c++. My problems is that cmake doesn't find an objective-c++ compiler installed on my computer. The first part of your answer isn't true because the compiler should, but does not already work. – maverick1989 Jun 10 '13 at 21:02
0

Try this one:

cmake -j4 -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -D CMAKE_C_COMPILER=/usr/bin/gcc ..

I had to explicitly set the compiler.

Brennan Cheung
  • 4,271
  • 4
  • 30
  • 29