1

I have my own program with plugins (dynamic shared libraries) on a linux (ubuntu) system. My libraries (plugins) use OpenCV (maybe not so important).

My plugins are in /usr/local/lib/mysoft/.

I have compiled my program successfully even with libraries, successfully installed so everything seems to be OK up to this point.

When I run my program, it loads a bunch of these libraries based on some configuration file. I have several libraries which are loaded successfully but I cannot load one library. It gives me error when loading (used dlopen() to open the library):

/usr/local/lib/mysoft/libMyPlugin2.so: undefined symbol: _ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi
Segmentation fault (core dumped)
Tue Nov 20 19:11:29 CET 2012

It obviously has some problems to find cv::resize which is part of OpenCV but I don't understand why.

I checked following things:

  • OpenCV is probably correctly installed since other libraries use it as well and are loaded without problems
  • no dependencies of my program, libMyPlugin2.so or OpenCV are missing (checked with ldd)
  • Architecture of all libraries and binaries seems to be the same (I checked it with objdump -f)

Does anybody have an idea what am I doing wrong?

This post seems to be so relevant but still didn't help: Linux shared library that uses a shared library undefined symbol

Community
  • 1
  • 1
bubo
  • 591
  • 1
  • 6
  • 11
  • You might have several versions of OpenCV installed and a wrong version is chosen at run time. – Andrey Kamaev Nov 20 '12 at 21:22
  • Might be Andrey Kamaev is correct, but try building OpenCV in debug mode and run it with debug libraries. OpenCV on Ubuntu / Linux distros has some prerequisites that you will catch only in debug mode. – Kamath Nov 20 '12 at 21:36
  • It was correct that I had multiple versions of OpenCV installed but I linked the right one (chcecked with ldd). Even after uninstall and now when I have only a single version it acts the same (I even rebuilded my software to be sure that it's linked with the single vwersion). – bubo Nov 21 '12 at 06:53
  • `_ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi` obviously looks like a C++ mangled name, so it seems that you have a C++ ABI compatibility problem. What compiler do you use and what compiler was used to build the library? Maybe, the mangling algorithm has changed slightly in another compiler version, so you get most of the symbols right. – Dmytro Sirenko Nov 21 '12 at 10:39
  • Actually I use the the CMake to generate Makefiles but you're right - it seems that there is problem with different compiler versions. Do you know if it's possible to analyse the problem based on binaries? I specified the same compiler to the CMake for OpenCV and my stuff but it didn't solve my problem (I used CMAKE_CXX_COMPILER=/usr/bin/g++ and CMAKE_CC_COMPILER=/usr/bin/gcc). – bubo Nov 21 '12 at 15:04

1 Answers1

1

Well I found the problem, hopefully it can help others...

The problem - I was missing one OpenCV library when compiling. So I replaced "opencv_core opencv_highgui" by "opencv_core opencv_imgproc opencv_highgui" and everything works.

So although I was able to compile it one of the dependencies was missing - I guess something has changed in OpenCV cause these sources worked perfectly (even with build) with older versions of the OpenCV.

bubo
  • 591
  • 1
  • 6
  • 11