How can I compile and build a program using external library with command line tools come with Xcode?

StackOverflow https://stackoverflow.com/questions/11816688

Question

I am coding a computer vision program, which is using OpenCV 2.4, by Xcode 4.4. I want to compile and make it in the Terminal by g++ or make command. But the system shows a lot of errors that the compiler cannot find the "opencv2/opencv.hpp" file and Vec3d, etc..!

My question is how to configure the system the I can make and build the code in Terminal? Thanks.

Was it helpful?

Solution

First, you need to have command line tools (I guess you already have it)

  1. Bring up Preference in Xcode
  2. Select "Downloads" tab
  3. Select "Components' tab
  4. Click 'install' on the command line tools line.

Then, you need to install OpenCV. I suggest to use Homebrew

  1. setup homebrew, then
  2. brew install opencv

It will install library in /usr/local, which is in g++'s standard lookup path, thus should be ok.

If you still need help, post the log file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top