Ubuntu – Error while loading shared library libz.so.1 while cross compiling for arm-linux

armcompilingcross-compilationgccshared library

I'm trying to cross compile an opencv app on Ubuntu 14.04 to run on an ARM core. I can compile the open cv app fine on Ubuntu with

g++ test.c -o test -I /usr/include/opencv -I /usr/include/opencv2 -L /usr/local/lib/ -lopencv_core -lopencv_imgproc -lopencv_highgui

It compiles and I have a testl.bin in my directory.

However, when I alter the compiler for my arm core

arm-linux-gnueabi-g++ test.c -o test -I /usr/include/opencv -I /usr/include/opencv2 -L /usr/local/lib/ -lopencv_core -lopencv_imgproc -lopencv_highgui

I'm met with the error

error while loading shared libraries: libz.so.1: cannot open shared object file: no such file or directory.

When I try and install this library apt-get lets me know it's at it's newest version and there's nothing to be installed.

Can someone help me out?

Best Answer

I had the same problem - it is a bit confusing. The cross-compiler may be 32-bit (my case), so it is complaining about missing 32-bit library:

sudo apt-get install zlib1g:i386

Then cross-compiler should work.

Related Question