【问题标题】:How to build opencv c++ programs in sublime text 2 in linux如何在 Linux 中以 sublime text 2 构建 opencv c++ 程序
【发布时间】:2013-03-08 16:59:26
【问题描述】:

我正在尝试使用 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`

【问题讨论】:

  • 您将“source.c++”作为选择器而不是“source.cpp”。我不知道这是否有问题。
  • 没关系,因为它在默认的 c++.sublime-build 中是一样的

标签: linux sublimetext2 pkg-config


【解决方案1】:

我可能为时已晚,但我想你应该交换 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/

【讨论】:

  • 最新的有更新吗?我收到此错误:ld: library not found for -llibopencv_stitching.3.3.1.dylib
【解决方案2】:

对我来说,实际上来自 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"]
    }
}

【讨论】:

    猜你喜欢
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-25
    • 1970-01-01
    相关资源
    最近更新 更多