For the past week, I have been trying to run some simple OpenCV programs using the terminal. I have tried many tutorials and recommendations from various forums with little
I create a similar file that maybe can help you.
First I use:
sudo brew install opencv
Then I install the opencv.3.0 according to the hint given by the terminal. Then in the .cpp file which needs the API from opencv, I use:
#include "opencv2/opencv.hpp"
As my only include file about opencv. Actually, at that project I use highgui, core, and imgprog. But no worries here, I will show you how to solve them in linking part.
After you finish your project, you are going to compile your project on the terminal.
Because I also used the JNI interface, so I still need to link the jni.h.
Here we go:
g++ xxxx.cpp xxx.cpp -lstdc++ -fPIC -shared (to create a shared object)
-I/absolute path/ (we can use -I to be followed with the absolute path of the library you need to use )
-I/Users/yuanzhan/Downloads/OpenCV-2.0.0/src/
-I /Users/yuanzhan/Downloads/OpenCV-2.0.0/include/opencv/ -I/usr/local/Cellar/opencv3/3.1.0_3/lib -lopencv_core (open the library for use if you use the API fro here)-lopencv_highgui -lopencv_imgproc -L.(i put the cv2. on local otherwise you can add the absolute path here) -lcv2(use the package) -v -o libopenCvSDK.so(generate my .so package).