4

There are various versions of this question but I havnt been able to find what Im looking for.

I have a bunch of cpp files in the OpenCV samples directory. I would like to create a project in XCode that can compile and build all the executables. I opened a new project, added all the sample source files, included the correct header files and the right link paths and then got stuck because I dont know how to make the project build and link executables for each relevant cpp file. Im guessing Im doing this completely wrong so any help would be appreciated.

2 Answers 2

5

In Xcode 4, click on the Project icon in the navigator which should bring up a Projects and Targets section in the main pane. There should be an "Add Target" button at the bottom. Just add a new target and then specify which source files you want in the "Compile Sources" section in the "Build Phases" tab.

Xcode 3 is should be similar. Add a new target and tell it which source files to use.

HTH

Sign up to request clarification or add additional context in comments.

1 Comment

Thats what I did but its a laborious task to add 40 targets by hand. I had hoped there was some way to automate it.
1

You don't need XCode to build samples, OpenCV on Mac OS X makes use of cmake to generate makefiles which, in turn, are being consumed by gcc.

Please read: http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port

So, assuming you have cmake installed, in OpenCV source directory run:

sudo cmake -D BUILD_EXAMPLES=ON -G "Unix Makefiles" .

You have Makefile in your 'samples' directory now and can compile samples:

cd samples
sudo make

The sample binaries will be put in the 'bin' directory. Voilà!

1 Comment

My intention is not to just compile the samples but also to have them all under one roof so that I can edit them and share files between them. Ive compiled all of them using the build scripts but I actually want a single xcode project where I can manage everything from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.