Macports, compiling using G++ in Terminal

asked 2014-05-11 10:28:28 -0600

Marsstar gravatar image

updated 2014-05-11 10:37:55 -0600

I installed OpenCV for mac with MacPorts by following this video: https://www.youtube.com/watch?v=mJWVz3ncRoo

When I ran this script as shown in that video (compiled with the G++ compiler), it runs nicely and I've put in this here into the Terminal: g++ main.cpp -o main -I/opt/local/include -L/opt/local/lib -lopencv_highgui.2.4.9 -lopencv_core.2.4.9

image description

The code above works just fine, but the sample code from this site "http://opencvlover.blogspot.ch/2011/07/accesing-camera-using-opencv.html" showed up some errors in the Terminal. I've put this into the Terminal: g++ camera.cpp -o camera -I/opt/local/include -L/opt/local/lib -lopencv_highgui.2.4.9 -lopencv_cv.2.4.9 -lopencv_iostream.2.4.9

and the Terminal outputted this:

image description

Why am I getting this error, although I linked it correctly? Can you recommend me any tutorial, that uses a G++ compiler on a OS X with the Terminal? THANKS. Marsstar

edit retag flag offensive close merge delete

Comments

the 2nd example is using the outdated c-api. you should definitely avoid it

(well, yea, and they moved the old c-headers into an opencv folder [the c++ api is in opencv2], so you'll need -I/opt/local/include/opencv in your g++ cmdline) - but please, don't bother. don't try to revive the zombies.

berak gravatar imageberak ( 2014-05-11 10:37:11 -0600 )edit