"The C++ compiler "/usr/bin/c++" is not able to compile a simple test program." When trying to install OpenCV

Thanks to everybody's help, I was able to solve my issue.

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

it was because my $PATH was messed up (I think it happened when I tried to add Android SDK to $PATH)

I cleared the .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 it worked like charm.


I had the same problem - what worked was to remove the command line tools:

rm -rf /Library/Developer/CommandLineTools

Then reinstall the command line tool:

xcode-select --install

Who knows what that script is doing...and I don't have time to investigate so there you go...