I cross-compiled OpenCV for arm following this guide, and built this sample program.

When I first ran it like this:

./DisplayImage image.png

I got:

./DisplayImage: error while loading shared libraries:
libopencv_highgui.so.3.1: cannot open shared object file: No such file or directory

So I figured it needs the library libopencv_highgui.so.3.1. So I added all these libs to /lib:

(1) libopencv_highgui.so
(2) libopencv_highgui.so.3.1
(3) libopencv_highgui.so.3.1.0

symlinks: (1) -> (2) -> (3)

But now I'm getting:

./DisplayImage: error while loading shared libraries:
lib/libopencv_highgui.so.3.1: internal error

I ran file on both the library and the executable to check their info, and this is the output:

.../opencv/platforms/linux/my_build/lib$ file libopencv_highgui.so.3.1.0
libopencv_highgui.so.3.1.0: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=1107ba22b36437bedb37dbfe0250626c14759be9, not stripped

.../opencv_sample$ file DisplayImage
DisplayImage: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=aef57fe79d0928ca3afdff8d1b65268e1ad72e77, not stripped

Running readelf -d DisplayImage | grep NEEDED produces:

 0x00000001 (NEEDED)                     Shared library: [libopencv_highgui.so.3.1]
 0x00000001 (NEEDED)                     Shared library: [libopencv_imgcodecs.so.3.1]
 0x00000001 (NEEDED)                     Shared library: [libopencv_core.so.3.1]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]

I found all of them on my target except ld-linux-armhf.so.3.

What could be causing this "internal error" problem?

  • Are you on Android? Or some other platform? Also be aware of CMake. It may be a cross-platform makefile generator, but it does a rather poor job at times. We tried to supply one in our project, but we had to yank it from the distribution because it had so many problems.
    – user56041
    Nov 8, 2016 at 4:05
  • I'm on arm linux (Yokto). Yeah you might be right... I am using cmake. I just gave it up and switched to Ubuntu. There I can just sudo apt-get install it and go.
    – Alaa M.
    Nov 8, 2016 at 7:24

1 Answer 1


when a binary is compiled it can use shared libraries, these libaries are references with a version number so that you attain a library verion that is supported.

sometimes you can get away with sym linking a newer libary to an older name, the binary will attempt to use this one.

however this does not mean the binary will support that version. Some functions may have changed, some functions removed or added, so on.

Therefore i'd suggest re-compiling the binary against a newer libary version, an incompatibilities will be flagged at compile time.

you can see library dependencies using ldd.


$ ldd /bin/ls
    linux-vdso.so.1 (0x00007ffc65ff3000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f9033f91000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9033bf1000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f9033979000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9033771000)
    /lib64/ld-linux-x86-64.so.2 (0x0000558f25845000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9033551000)

Edit: ps... you can't just copy across libs as they have their own dependencies. your cross-compile machine will need similar lib versions to compile against.

  • I meant that I crossed compiled the libs on my host machine (Ubuntu) and then copied them to my target (arm)
    – Alaa M.
    Oct 30, 2016 at 15:44
  • don't copy libs across, compile static or cross compile for the destination host's libs. Oct 30, 2016 at 15:52
  • Again, I cross compiled for the destination... Then copied them there. I don't understand what's the problem...
    – Alaa M.
    Oct 30, 2016 at 15:54
  • Why upvote this answer? It's wrong and not eligible to take the bounty.
    – Alaa M.
    Nov 2, 2016 at 5:33
  • 1. what is output of ldd DisplayImage, 2. you can't copy "libopencv_highgui.so.3.1.0" from the build machine (it has it's own dependencies there). 3. you can't sybolic link libopencv_highgui.so.4 to libopencv_highgui.so.3.1.0 on dest machine, it's a different version. 4. compile static on src machine to use libopencv_highgui.a. 5. compile to use libopencv_highgui.so.4 or whatever the version is on dest machine. Nov 2, 2016 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .