【问题标题】:Compiling a node addon w/ opencv on OS X and Heroku在 OS X 和 Heroku 上编译带有 opencv 的节点插件
【发布时间】:2015-01-09 02:31:06
【问题描述】:

我在使用 os x 和 heroku 上的 opencv 编译节点插件时遇到问题。但是,在 ubuntu 上它工作正常。

我正在使用 vagrant 文件:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.provision :shell, :inline => $BOOTSTRAP_SCRIPT # see below
end

$BOOTSTRAP_SCRIPT = <<EOF
  set -e # Stop on any error

  # Make vagrant automatically go to /vagrant when we ssh in.
  echo "cd /vagrant" | sudo tee -a ~vagrant/.profile

  sudo apt-get update -y
  sudo apt-get install -y build-essential python g++ make curl git
  sudo apt-get install -y libopencv-dev libeigen3-dev

  curl http://nodejs.org/dist/v0.10.35/node-v0.10.35-linux-x64.tar.gz | \
    tar -C /usr/local/ --strip-components=1 -xvz; \
    npm update -g npm

  echo VAGRANT IS READY.
EOF

我有一个binding.gyp 文件:

    {
      "targets": [{
        "target_name": "module",
        "sources": [
          "node_src/module.cc",
          "src/Candidate.cpp",
          "src/Image.cpp",
          "src/LearnerEngine.cpp",
          "src/ShaheenTracker.cpp"
        ],
        'libraries': [
          '<!@(pkg-config --libs opencv)'
        ],
        'include_dirs': [
          'include/',
          "<!(node -e \"require('nan')\")"
        ],
        'cflags': [
          '<!@(pkg-config --cflags "opencv <= 3.0.0" )', '-std=c++11', '-Wall', '-fPIC'
        ],
        'cflags!': ['-fno-exceptions'],
        'cflags_cc!': ['-fPIC', '-fno-rtti', '-fno-exceptions', '--enable-auto-import'],
        "conditions": [
          ['OS=="mac"', {
            'xcode_settings': {
              'OTHER_CFLAGS': [
                "-mmacosx-version-min=10.7",
                "-std=c++11",
                "-stdlib=libc++",
                '<!@(pkg-config --cflags opencv)'
              ],
              "GCC_ENABLE_CPP_RTTI": "YES",
              "GCC_ENABLE_CPP_EXCEPTIONS": "YES"
            }
          }]
        ]
      }]
    }

在 OS X 上,我可以使用 npm i 进行编译。但是,我无法运行它,因为我收到以下错误:

1): Symbol not found: __ZNK2cv11_InputArray12getMatVectorERNSt3__16vectorINS_3MatENS1_9allocatorIS3_EEEE

在 Heroku 上,我使用 https://github.com/ddollar/heroku-buildpack-apt 获取软件包并拥有以下 Aptfile:

libeigen3-dev
libopencv-dev

但是,我收到以下错误:

remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_contrib.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_core.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_features2d.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_flann.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_gpu.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_legacy.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_ml.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_ocl.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_photo.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_stitching.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_superres.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_ts.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_video.so: No such file or directory
remote:        g++: error: /usr/lib/x86_64-linux-gnu/libopencv_videostab.so: No such file or directory

我认为这是pkg-config 的问题。

我做错了什么?

【问题讨论】:

  • 在我看来,您还没有安装 libopencv_*.so 文件...sudo apt-get install -y libopencv-dev 是否安装了 opencv 或只是一些东西?因为在谷歌的任何页面上,我都看到 OpenCV 是从 git repo 或一些存档(.tar、.zip ...)安装的

标签: node.js opencv heroku pkg-config buildpack


【解决方案1】:

libopencv-dev 是一个依赖文件。你仍然需要从 sourceforge 下载主文件或从 git 克隆它然后制作。

单独安装OpenCV应该可以解决问题。
http://wiki.nuigroup.com/Installing_OpenCV_on_Mac_OS_X
这是一个用于在 Ubuntu 中安装 OpenCV 的脚本供参考
https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_5.sh


希望这会有所帮助!!

【讨论】:

    猜你喜欢
    • 2012-01-13
    • 1970-01-01
    • 2016-11-04
    • 1970-01-01
    • 2012-05-01
    • 2016-01-14
    • 2016-02-10
    • 1970-01-01
    • 2023-03-22
    相关资源
    最近更新 更多