I am using xcode to compile my opencv project, and I have some settings as below:
HEADER_SEARCH_PATHS = /usr/local/include
LIBRARY_SEARCH_PATHS = /usr/local/lib
OTHER_LDFLAGS = -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab
I want to know what shall I write by terminal command rather than setting of xcode.
You can use:
If you installed
OpenCV
withhomebrew
and you also installed thepkgconfig
package withhomebrew
, the package can tell you the settings you need itself - far more accurately than you can guess them.The easy way is to ask
pkgconfig
to list all the packages it knows about:So, now you know the package name is plain and simple
opencv
, and you can find the flags you need like this:Which means your compilation and linking becomes simply:
If you do that in a Makefile, you will need to double up the
$
signs.If your system is not so well installed, you may need to find the
pkgconfig
file yourself. So you would do:Then you can access that file specifically like this: