转自:http://subokita.com/2013/04/21/configuring-sublime-to-work-with-opencv-on-mac/
------------------------------------------------------------------------------------------------------------------------
自己试了以后,感觉这个方法还是不太好使,但还是转载一下,留作备忘
------------------------------------------------------------------------------------------------------------------------
So, I just bought Sublime Text from http://www.sublimetext.com, which is supposed to be a very good cross platform text editor. I’ve been programming OpenCV applications using XCode, but rarely using editor or even compiling it from command line.
However, after tinkering a bit, I’ve managed to create a this built system for Sublime, which should allow you to compile and run OpenCV / C++ application from it. Just go to Tools > Build System > New Build System
My OpenCV was installed using HomeBrew, which has pkg-config information for opencv already created inside /usr/Local/Cellar/opencv/2.4.4/lib/pkgconfig/, thus you can utilize pkg-config to generate the include and library flags for g++ from it.
{
"cmd": ["g++", "-Wall", "-Wextra", "${file}", "-o", "${file_path}/${file_base_name}",
"-I/usr/local/Cellar/opencv/2.4.4/include/opencv",
"-I/usr/local/Cellar/opencv/2.4.4/include",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_calib3d.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_contrib.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_core.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_features2d.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_flann.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_gpu.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_highgui.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_imgproc.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_legacy.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_ml.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_nonfree.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_objdetect.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_ocl.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_photo.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_stitching.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_ts.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_video.dylib",
"/usr/local/Cellar/opencv/2.4.4/lib/libopencv_videostab.dylib"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' `/usr/bin/pkg-config --cflags --libs /usr/Local/Cellar/opencv/2.4.4/lib/pkgconfig/opencv.pc` && '${file_path}/${file_base_name}' "]
}]
}