title: Compiling a node addon w/ opencv on OS X and Heroku
body: <p>I'm having an issue compiling a node add on with opencv on os x and heroku. however, on ubuntu it works fine.</p>
  
  <p>I'm using the vagrant file:</p>
  
  <pre><code>Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/trusty64"
    config.vm.provision :shell, :inline =&gt; $BOOTSTRAP_SCRIPT # see below
  end
  
  $BOOTSTRAP_SCRIPT = &lt;&lt;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
  </code></pre>
  
  <p>I have a <code>binding.gyp</code> file:</p>
  
  <pre><code>    {
        "targets": [{
          "target_name": "module",
          "sources": [
            "node_src/module.cc",
            "src/Candidate.cpp",
            "src/Image.cpp",
            "src/LearnerEngine.cpp",
            "src/ShaheenTracker.cpp"
          ],
          'libraries': [
            '&lt;!@(pkg-config --libs opencv)'
          ],
          'include_dirs': [
            'include/',
            "&lt;!(node -e \"require('nan')\")"
          ],
          'cflags': [
            '&lt;!@(pkg-config --cflags "opencv &lt;= 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++",
                  '&lt;!@(pkg-config --cflags opencv)'
                ],
                "GCC_ENABLE_CPP_RTTI": "YES",
                "GCC_ENABLE_CPP_EXCEPTIONS": "YES"
              }
            }]
          ]
        }]
      }
  </code></pre>
  
  <p>On OS X, I can compile with <code>npm i</code> fine. However, I can't run it as I get the following error:</p>
  
  <pre><code>1): Symbol not found: __ZNK2cv11_InputArray12getMatVectorERNSt3__16vectorINS_3MatENS1_9allocatorIS3_EEEE
  </code></pre>
  
  <p>On Heroku, I am using <a href="https://github.com/ddollar/heroku-buildpack-apt" rel="nofollow">https://github.com/ddollar/heroku-buildpack-apt</a> to get the packages and have the following Aptfile:</p>
  
  <pre><code>libeigen3-dev
  libopencv-dev
  </code></pre>
  
  <p>However, I get the following error:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I think that's a <code>pkg-config</code> issue.</p>
  
  <p>What am I doing wrong?</p>