I would like to use OpenCV library with Code::Blocks.
I have already installed OpenCV with the following command line :
sudo port install opencv
The above command created multiple opencv folders in /opt/local/include/, /opt/local/var/macports/software/, /opt/local/var/macports/sources/ and /opt/local/share/.
What should I do now to make it work with Code::Blocks ?
[EDIT 24.06]
Thanks to cyriel, I have managed to install OpenCV and make it work with QT Creator.
To install Homebrew and OpenCV just type the following command lines :
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew doctor
brew tap homebrew/science
brew install opencv
Then, set cyriel's project settings and try to compile and execute following source code :
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image;
image = imread("/image-path/image-filename.image-format", CV_LOAD_IMAGE_COLOR);
if(! image.data )
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );
imshow( "Display window", image );
waitKey(0);
return 0;
}
and it works just fine !
Regarding Code::Blocks
In Build options > Linker Settings, I have linked all the *.a and *.dylib files that are in the /usr/include/lib/ folder.
In Build options > Search directories > Compiler, I have added /usr/local/lib, /usr/local/include/opencv and /usr/local/include folders
In Build options > Search directories > Linker, I have added /usr/local/lib and /usr/local/include/opencv
I am not familiar with external libraries so I m not really sure if my configuration is correct but it doesn't seem to compile correctly.
-------------- Run: Debug in ImgDownsampling-V1 (compiler: GNU GCC Compiler)---------------
Checking for existence: /Users/Universe/Desktop/Coding/ImgDownsampling-V1/bin/Debug/ImgDownsampling-V1 Executing: osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script "/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:.:/usr/local/lib:/usr/local/include/opencv /Users/Universe/Desktop/Coding/ImgDownsampling-V1/bin/Debug/ImgDownsampling-V1 "' -e 'end tell' (in /Users/Universe/Desktop/Coding/ImgDownsampling-V1/.)
Terminal doesn't show up...
[EDIT 24.06]
I have tried to change settings and managed to make it work !
Same Code::Blocks configuration as before except that I have cleared all the folders in Build options > Search directories > Linker.