Running 32 bit exe on Ubuntu :libudev.so : cannot open shared object file: No such file or directory

Raulp picture Raulp · Jan 16, 2014 · Viewed 15.6k times · Source

I am trying to run an exe which uses libudev.so but it gives this error :

error while loading shared libraries: libudev.so.0: cannot open shared object file: No such file or directory

Running uname -a gives :

3.5.0-44-generic #67~precise1-Ubuntu SMP Wed Nov 13 16:16:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

I am using Ubuntu 12.04

I have checked /lib /lib32 /lib64 there is no libudev in there but in Synaptic manager I can see libudev0 installed (see image below)

libudev on Synaptic Manager and I could find it in /lib/x86_64-linux-gnu/libudev.so.0.

What could be wrong?

Answer

Anton Kovalenko picture Anton Kovalenko · Jan 16, 2014

It turns out (as I suspected) that you tried to run a 32-bit executable on a 64-bit system. 64-bit Linux kernel is capable of running 32-bit executables (that's why you don't get "exec format error"), but it needs a separate set of (32-bit) libraries: 64-bit version of libudev.so.0 is useless for a 32-bit program. (See ld.so manpage for some details on shared library dependency resolution).

Modern Debian-based distributions support simultaneous library installation for several architectures. apt-get install libudev0:i386 should get a 32-bit version of the library and all its dependencies (there might be plenty of them if it's the first time you use a 32-bit application). If you upgraded from an ancient installation, you might need to add i386 to architectures supported by dpkg, like this:

dpkg --add-architecture i386

Some advices to use if the program needs some other libraries as well:

  • Use ldd to see all the dependencies at once (and what's missing)
  • Install apt-file and run apt-file update, so you can look up a package name by a file name, even if the package is not currently installed (like this: apt-file search /libudev.so.0)

There was also an old Debian way of getting 32-bit libraries on a 64-bit system: ia32-libs package in amd64 repositories provided a set of libraries, conceptually "everything your application might need". Don't use this approach unless you're running Debian squeeze or earlier (or a debian-based distro of the same age). Even when it worked, there was no guarantee that the program doesn't need some other library as well. Ia32-libs was useful when multiarch support was not ready yet, and that was some years ago.