0
votes

OpenCV used to work fine on my Mac OS(10.9, Mavericks). But there are some problem after I upgraded the dependent library libpng. For a simple program:

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main( int argc, char** argv )
{
  Mat image;
  image = imread( argv[1], 1 );

  if( argc != 2 || !image.data )
    {
      printf( "No image data \n" );
      return -1;
    }

  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
  imshow( "Display Image", image );

  waitKey(0);

  return 0;
}

It compiled smoothly by CMake. But When I run it, the error pops out:

dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng15.15.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib Reason:
image not found 
Trace/BPT trap: 5

I've checked the directory /usr/local/opt/libpng/lib/. It seems that the current version of libpng is 16 since there symbolic links such as

libpng.a          libpng16.16.dylib libpng16.dylib
libpng.dylib      libpng16.a        pkgconfig

I've tried "brew upgrade opencv" and opencv is the latest version(2.4.9). Typically opencv should support libpng16 since it is up to date. I don't know the difference between libpng15 and libpng16. Should I uninstall this libpng16 and installed libpng15? How to do that?

2

2 Answers

0
votes

Actually I solved this by installed another version of libpng (libpng15), which seems to be needed by the current opencv version (2.4.9).

0
votes

You should recompile OpenCV against the new libpng as it changes its ABI version (the dylib name changed). If you installed this via homebrew, I'd say its an issue in their package (unless this kind of upgrade needs manual intervention, i.e. recompile the dependent binaries against the new library version).