我正在尝试使用sublime text 2构建opencv源代码,但似乎使用pkg-config链接opencv库时出现问题
我的 C ++。sublime-build
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ -ggdb '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}' `pkg-config --cflags --libs opencv`"]
}
]
}
PS:当我尝试从终端编译我的程序时,这个编译成功了。
g++ -ggdb source.cpp `pkg-config --cflags --libs opencv`
答案 0 :(得分:3)
我可能为时已晚,但我想你应该交换 pkg-config --cflags --libs opencv
和
的&安培;&安培; '$ {file_path} / $ {file_base_name}'的位置,因为pkg-config
部分用于编译,而&&& '$ {file_path} / $ {file_base_name}'部分似乎是执行部分。
“cmd”:[“bash”,“ - c”,“g ++ -ggdb'$ {file}'-o'$ {file_path} / $ {file_base_name}'pkg-config --cflags --libs opencv
&&' $ {file_path} / $ {file_base_name}'“]
如果您有兴趣,我在这里创建了自己的构建系统:http://subokita.com/2013/04/21/configuring-sublime-to-work-with-opencv-on-mac/
答案 1 :(得分:0)
对我来说,实际上来自sub_o的命令并没有帮助,但是他的输入让我理解了它的工作方式,更好。所以我想分享我的构建系统。 我通过Homebrew安装了所有东西(opencv,pkg-config,...)。
{
"cmd": ["bash", "-c", "g++ '$file' -o '$file_base_name' '-I/usr/local/include' `pkg-config --cflags --libs opencv`"],
"selector": "source.c++",
"windows":
{
"cmd": ["cl", "/Fo${file_path}", "/O2", "$file"]
}
}