- How To Solve “cannot open shared object file” Error in Ubuntu-based Linux Distributions
- Fix ‘cannot open shared object file: No such file or directory’ error
- What are shared object files? How does the above command fixes the issue?
- Alternate method to fix ‘cannot open shared object file’ error
- Nothing works, what now?
- ImportError: libGL.so.1: cannot open shared object file: No such file or directory
- 10 Answers 10
- How do I resolve a «Cannot open shared object file libudev.so.0» error?
- 15 Answers 15
- For ubuntu 14.04 and above
- For previous versions
- How to solve:
- For a 64-bit system:
- what allows to prevent the «error while loading shared libraries: libudev.so.0: wrong ELF class: ELFCLASS32»
- For a 32-bit system:
- what allows to prevent the «error while loading shared libraries: libudev.so.0: wrong ELF class: ELFCLASS64» ( note that’s a guess, I’m on a 64 bit system )
- Linux error while loading shared libraries: cannot open shared object file: No such file or directory
- 19 Answers 19
- ldconfig
- Dev package or wrong version
- Library location
How To Solve “cannot open shared object file” Error in Ubuntu-based Linux Distributions
Last updated February 17, 2021 By Abhishek Prakash 79 Comments
There is a list of common errors I often see in Ubuntu. There is problem with merge list, then there is BADSIG error, and a number of common Ubuntu update errors.
One of such common errors which I often see while installing a program from its source code is error while loading shared libraries. The full error generally looks like this:
error while loading shared libraries:
cannot open shared object file: No such file or directory
For example, I was trying to use FreeRADIUS server and it showed me this error:
The reason behind this error is that the libraries of the program have been installed in a place where dynamic linker cannot find it.
Fix ‘cannot open shared object file: No such file or directory’ error
In this quick tutorial, I’ll show you the quickest and the easiest way to fix this error while loading shared libraries.
All you need to do is to open terminal (Ctrl+Alt+T) and type the following command:
This one liner solution may not be applicable in all cases and may not fix the problem for you but till date this command has never failed me.
What are shared object files? How does the above command fixes the issue?
You see, in C/C++, a .so (shared object) is a compiled library file. It is called shared object because this library file can be shared by several programs. These generated libraries are usually located in /lib or /usr/lib directories.
Now if you wonder how did this tiny command fixed this problem, you should read the man page of ldconfig which says:
ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib). The cache is used by the run-time linker, ld.so or ld-linux.so. ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their links updated.
I hope this quick fix helps you in eliminating the nasty error while loading shared libraries message in Ubuntu and other Linux.
If not, you can do some investigation and try to fix the issue the way it is mentioned in the next section.
Alternate method to fix ‘cannot open shared object file’ error
The above discussed method fixes the issue if the library in question is available in your system. But that may not always be the case.
If you do not have the program installed on your system, you won’t have its library file. The ldconfig cannot do anything if there is no library file in the first place.
So, the alternate method is to install the required program and it should create the library automatically.
Let me show it to you by an example. Let’s say you see this error:
The problem is with libgobject version 2.0. The version number is important because some programs depend on a specific version of the library and if they don’t find, they complain about it.
Now, apt provides the search option that can be used for searching a package and knowing its version before installing it.
Now, this librust-gobject-sys-dev package could be what you need if you know that you were trying to run a Rust program. But what if it was a Python program you were running that complained about it?
You can widen your search by removing the lib from the package name while searching. The lib signifies library and libraries may be provided by a generic package that could be named gobject-xyz.
It would be a good idea to search for the string in the names of the package (instead of description) to get more concise results.
In the above truncated output, you’ll have to see if the package is related to the original program you were trying to run. You must also check the version of the library provided.
Once you have identified the correct package, install it like this:
Once installed, you may run the ldconfig command again to update the cache:
This method requires some effort on your end but this is how the dependencies are handled.
Nothing works, what now?
If you are unfortunate enough, the above methods might not work for you. What can you do?
First, keep in mind that the shared libraries may be used from other packages in some cases. If you were trying to run XYZ program and ABC program installs the correct version of the shared library, it may (or may not) work for you. You can give it a hit and trial.
Second, if you are trying to run a program which is too old or too new, it may require a library version which is not available for your Linux distribution.
What you may do is to check if you can use some other version of the program. For example, using Eclipse version 3 instead of version 4. This may help your case.
The other way would be to check the developers website or forums and see if you can manually install the correct version of the library from its source code. That requires a lot of effort (in 2020) but you don’t have a lot of options.
Did it work for you?
I hope I have make things a bit more clear for you. Did you manage to fix the issue of shared libraries in your system? If you have questions, suggestions, feel free to drop a comment. Ciao 🙂
Like what you read? Please share it with others.
Источник
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
i am trying to run cv2, and when i try to import it i get
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
the suggested solution online is installing
apt install libgl1-mesa-glx
but this is already installed and the latest version.Any help would be really helpful.Thanks in advance.
10 Answers 10
Add these lines to your Dockerfile
This is a little bit better solution in my opinion. Package python3-opencv includes all system dependencies of OpenCV.
Put this in the Dockerfile
Before the line
Even though the above solutions work. But their package sizes are quite big. libGL.so.1 is provided by package libgl1 . So the following code is sufficient.
Try installing opencv-python-headless python dependency instead of opencv-python . That includes a precompiled binary wheel with no external dependencies (other than numpy), and is intended for headless environments like Docker. This saved almost 700mb in my docker image compared with using the python3-opencv Debian package (with all its dependencies).
The package documentation discusses this and the related (more expansive) opencv-contrib-python-headless pypi package.
Источник
How do I resolve a «Cannot open shared object file libudev.so.0» error?
Trying to run Game Dev Tycoon on Ubuntu 64. It asks for the above object.
I ran sudo apt-get install libudev1:i386 and it came back already installed.
I have /lib/i386-linux-gnu/libudev.so.1 but no libudev.so.0 anywhere.
15 Answers 15
To fix, I linked libudev.so.1 to libudev.so.0 :
For ubuntu 14.04 and above
The easiest method I found was to just download the .deb (direct link to 64-bit download and to 32-bit download) and double click it to install it or use dpkg to install it:
For previous versions
In previous version of ubuntu this package was available in the official repositories. You can install with the following:
I had the same problem for a different program, but Sean’s accepted answer didn’t help me at all. On my upgraded install of 64-bit 13.04, libudev0 is not available either in 64-bit form or i386 form. And ia32-libs is already installed. So no dice.
What I had to do was a slightly modified version senshikaze’s more technical solution. I manually symlinked libudev.so.0 to libudev.so.1 in the x86_64 lib directory, thusly:
This fixed it for me.
For 64-bit Ubuntu, it is in the 32-bit libudev0 package.
You can install that with the following command:
This package was removed from Ubuntu in 14.04. You will need to install it from an older version.
This error might happen when trying to use nw executable from Node Webkit. Like this:
How to solve:
Get hex editor that allows you to change ASCII string of binary, eg. hexedit:
- In terminal( Ctrl + Alt + T ), run: sudo apt-get install hexedit .
- Follow instructions presented in terminal(type password if needed, confirm install).
- In my case: cd
/Dokumenty/node-webkit-* .
- Run: sudo hexedit nw .
- If using hexedit: Press Tab .
- Press Ctrl + S .
- Type: libudev.so.0 .
- Use arrow keys to select 0 in libudev.so.0 string.
- Press 1 on keyboard.
- Press Ctrl + X .
- Press Y to save changes.
You’re done. This also fixes problem with Atraci binary when following same instructions except hex editing Atraci file instead of nw.
The only answer here that works on Ubuntu 14.04 is the accepted answer, and since many comments point out that this can cause issues with the system down the road (although I don’t know about that myself) I came up with a compromise. This script will prompt (in the terminal) for your root password. It will create the symbolic link and launch the application (in my case, popcorn time). When you quit the application, it will use the existing sudo session to remove the symbolic link:
I just found a way to make this work, is pretty silly though.
I have Google Chrome installed on my system and Chrome has this shared object embedded. So, I just had to make a symbolic link to the library on Chrome installation directory.
It works pretty fine for me.
This was simplest solution I found
as Phil Strong pointed out
then link it as libudev.so.0
i did this on 14.04, but should be similar. just delete the package and re-install. the correct libraries are installed appropriately.
i’m sure the other answers work, but i have a basic beef in modifying file system objects that are managed by configuration management packages.
This is what I used to solve the same problem on 32 bit Ubuntu 15.04.
UPDATE I made a bash script to wrap around the program you want to execute. You can add it to your local bin folder and just start the program without the copy & pasting or running shell scripts.
OLD ANSWER In Ubuntu 14.04 I was getting the error message from the Dart Editor when trying to use Live Preview (Chromium). The error was solved by installing libudev1 and creating a symbolic link.
I also used the script mentioned above by TenLeftFingers to execute DartEditor.
If the Dart Editor doesn’t execute make sure JAVA is installed and that is not a permission issue.
and make the IDE executable:
This worked for me.
I was getting the same error on my 32-bit system after upgrading from Xubuntu Precise to Trusty. This fixed it for me:
I found it here. With absolutely no parameters, I’m not quite sure how this fixed it, but it did. What I liked best is that it didn’t require doing anything that would potentially cause problems for me in the future, and didn’t require me hunting down any packages.
If anyone stumble upon this page while digging the web for fixes on the libudev.so.0 & the Emotiv Epoc SDK Dev Edition on Ubuntu, I hope the following will help:
// my config is 64bit Ubuntu 13.04
For a 64-bit system:
sudo ln -sf /lib/x86_64-linux-gnu/libudev.so.1. /lib/x86_64-linux-gnu/libudev.so.1
sudo ln -sf /lib/x86_64-linux-gnu/libudev.so.1 /lib/x86_64-linux-gnu/libudev.so.0
what allows to prevent the «error while loading shared libraries: libudev.so.0: wrong ELF class: ELFCLASS32»
sudo ln -sf /lib/x86_64-linux-gnu/libudev.so.1 /usr/lib/libudev.so.0
For a 32-bit system:
sudo ln -sf /lib/i386-linux-gnu/libudev.so.1. /lib/i386-linux-gnu/libudev.so.1
sudo ln -sf /lib/i386-linux-gnu/libudev.so.1 /lib/i386-linux-gnu/libudev.so.0
what allows to prevent the «error while loading shared libraries: libudev.so.0: wrong ELF class: ELFCLASS64» ( note that’s a guess, I’m on a 64 bit system )
sudo ln -sf /lib/i386-linux-gnu/libudev.so.1 /usr/lib/libudev.so.0
The EmotivControlPanel, EmoKey, EmoComposer, the Java examples & little customized Qt examples should be able tu run after doing the above ( I already tried all the steps above + others found on the web ( stack overflow, .. ), but none were working for me, so that’s what I ended up doing after some «try & errors»
Last but not least, If anyone here knows how to run programs compiled against 32bit libs on a 64bit system WHILE SPECIFYING TO USE A PROVIDED 3RD PARTY 32BIT LIBRARY ?
more precisely, for those who knows what I’m talking about, how am I supposed to run the «EmoCube» & «BlueAvatar» Qt examples on my 64bit system ?
—> for what I’ve tried so far, the most I could get was: «error while loading shared libraries: libedk.so.1: wrong ELF class: ELFCLASS64»
I guess that a symlink to that lib in the i386 directory wouldn’t make it ( although I did not try it yet ), so if anyone has an answer . I.m looking forward to reading it.
Источник
Linux error while loading shared libraries: cannot open shared object file: No such file or directory
Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain.
Edit: OK I didn’t notice the .1 at the end was part of the filename. What does that mean anyway?
19 Answers 19
Your library is a dynamic library. You need to tell the operating system where it can locate it at runtime.
To do so, we will need to do those easy steps:
(1 ) Find where the library is placed if you don’t know it.
(2) Check for the existence of the dynamic library path environment variable( LD_LIBRARY_PATH )
if there is nothing to be displayed, add a default path value (or not if you wish to)
(3) We add the desire path, export it and try the application.
Note that the path should be the directory where the path.so.something is. So if path.so.something is in /my_library/path.so.something it should be :
Here are a few solutions you can try:
ldconfig
As AbiusX pointed out: If you have just now installed the library, you may simply need to run ldconfig.
ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).
Usually your package manager will take care of this when you install a new library, but not always, and it won’t hurt to run ldconfig even if that is not your issue.
Dev package or wrong version
If that doesn’t work, I would also check out Paul’s suggestion and look for a «-dev» version of the library. Many libraries are split into dev and non-dev packages. You can use this command to look for it:
This can also help if you simply have the wrong version of the library installed. Some libraries are published in different versions simultaneously, for example, Python.
Library location
If you are sure that the right package is installed, and ldconfig didn’t find it, it may just be in a nonstandard directory. By default, ldconfig looks in /lib , /usr/lib , and directories listed in /etc/ld.so.conf and $LD_LIBRARY_PATH . If your library is somewhere else, you can either add the directory on its own line in /etc/ld.so.conf , append the library’s path to $LD_LIBRARY_PATH , or move the library into /usr/lib . Then run ldconfig .
To find out where the library is, try this:
(Replace libraryname with the name of your library)
If you go the $LD_LIBRARY_PATH route, you’ll want to put that into your
/.bashrc file so it will run every time you log in:
Update
While what I write below is true as a general answer about shared libraries, I think the most frequent cause of these sorts of message is because you’ve installed a package, but not installed the «-dev» version of that package.
Источник