Can anyone provide me some detailed guide how to compile OpenCV 2.3.1 on OS X Lion with Xcode?
I\'m getting mad about this … I got the source, used cmake to create t
With small changes to @moosgummi answer below steps worked with Xcode 4.6 on Mac OSX 10.7 TEST code is included below.
Installation of OpenCV :
Get the current Version of MacPorts here.
Don't forget to add "/opt/local/(s)bin" to your environment PATH
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Keep your MacPorts up-2-date:
sudo port -v selfupdate
Install OpenCV with mac ports
sudo port install opencv
Configuring Xcode for using OpenCV
Create a new XCode project using the Command Line Utility/Standard Tool template. Name it and select C++
Select Project -> Edit Project Settings. Select the Build tab. Set Configuration to All Configurations
In the Architectures section, double-click Valid Architectures and remove all the PPC architectures if any.
Compiler for C/C++/Objective-C > Apple LLVM compiler 4.2 Language" > "C++ Standard Library", and select "libstdc++ (GNU C++ standard library)"
In the Search Paths section set Header Search Paths to /opt/local/include/
Please choose non-recursive as an option while adding that search path
Close the Project Info window
Select Project -> New Group and create a group called OpenCV Frameworks With the new group selected, select Project -> Add files to 'Your Project Name'
Press the "/" key to get the Go to the folder prompt. Enter /opt/local/lib Select libopencv_core.dylib, libopencv_highgui.dylib (you may need to add other library files from this folder to run other code.)
Uncheck Copy Items… and click Add
TEST CODE
Copy this code into your main.cpp file. It should open up a small window that is half shaded.
#include
#include
int main(int argc, char *argv[])
{
// Open the file.
IplImage *img = cvCreateImage( cvSize(100,200), IPL_DEPTH_8U, 3); //if (!img) {
// printf("Error: Couldn't open the image file.\n");
// return 1;
//}
// Display the image.
cvNamedWindow("Image:", CV_WINDOW_AUTOSIZE);
cvShowImage("Image:", img);
// Wait for the user to press a key in the GUI window.
cvWaitKey(0);
// Free the resources.
cvDestroyWindow("Image:");
cvReleaseImage(&img);
return 0;
}