Linux unable to load shared object

How to Solve «cannot open shared object file» Error in Ubuntu-based Linux Distributions

Complete detailed solution for fixing “error while loading shared libraries” error in Ubuntu-based Linux distributions.

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:

radiusd: error while loading shared libraries: libfreeradius-radius-2.1.10.so: cannot open shared object file: No such file or directory

The reason behind this error is that the libraries of the program have been installed in a place where the dynamic linker cannot find them. Let me show you how you can go about fixing this issue.

Fixing ‘cannot open shared object file: No such file or directory’ error

One quick way to fix this “error while loading shared libraries” automatically is to use ldconfig. All you need to do is to open the terminal (Ctrl+Alt+T) and type the following command:

This one-liner should solve the problem in most cases. However, if it doesn’t, I have discussed another method to handle this error. But before that, let me tell you what does the above command do.

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.

Читайте также:  Serial touch screen linux

An 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:

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

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.

[email protected]:~$ apt search libgobject Sorting. Done Full Text Search. Done librust-gobject-sys-dev/focal 0.9.0-2 amd64 FFI bindings to libgobject-2.0 - Rust source code

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 descriptions) to get more concise results.

[email protected]:~$ apt search --names-only gobject Sorting. Done Full Text Search. Done gobject-introspection/focal-updates 1.64.1-1~ubuntu20.04.1 amd64 Generate interface introspection data for GObject libraries libavahi-gobject-dev/focal 0.7-4ubuntu7 amd64 Development headers for the Avahi GObject library libavahi-gobject0/focal 0.7-4ubuntu7 amd64 Avahi GObject library libcairo-gobject-perl/focal,now 1.005-2 amd64 [installed,automatic] integrate Cairo into the Glib type system in Perl libcairo-gobject2/focal,now 1.16.0-4ubuntu1 amd64 [installed,automatic] Cairo 2D vector graphics library (GObject library) libghc-gi-gobject-dev/focal 2.0.19-1build1 amd64 GObject bindings libghc-gi-gobject-doc/focal,focal 2.0.19-1build1 all GObject bindings; documentation 

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:

sudo apt install package_name

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 that is too old or too new, it may require a library version that is not available for your Linux distribution. What you may do is 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 developer’s 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.

Читайте также:  Rimworld linux save location

Did it work for you?

I hope I have made things a bit more clear for you. Did you manage to fix the issue of shared libraries in your system? If you have questions, or suggestions, feel free to drop a comment. Ciao 🙂

Источник

When R(v3.2.5) launched then the error occur «unable to load shared object» on ubuntu 12.04

After I installed R v3.2.5 on ubuntu 12.04 (64bit), launch R on command line, I can see error like this:

*** R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. **Error in dyn.load(file, DLLpath = DLLpath, . ) : unable to load shared object '/usr/lib/R/library/stats/libs/stats.so': libm.so.11835d88: cannot open shared object file: No such file or directory During startup - Warning message: package ‘stats’ in options("defaultPackages") was not found** *** 

And I can find same error when I install some package. How can I resolve this one? And I add some information about stats.so

R# R CMD ldd /usr/lib/R/library/stats/libs/stats.so /usr/lib/R/library/stats/libs/stats.so: /usr/local/lib64/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3gf) linux-vdso.so.1 => (0x00007fffb75f6000) liblapack.so.3gf => /usr/lib/liblapack.so.3gf (0x00007f9cdef48000) libblas.so.3gf => /usr/lib/libblas.so.3gf (0x00007f9cdecca000) libgfortran.so.3 => /usr/local/lib64/libgfortran.so.3 (0x00007f9ccec89000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9cce98c000) libR.so => /usr/lib/R/lib/libR.so (0x00007f9cce3bf000) libgomp.so.1 => /usr/local/lib64/libgomp.so.1 (0x00007f9cce1b2000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9ccdf94000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9ccdbd6000) libgcc_s.so.1 => /usr/local/lib64/libgcc_s.so.1 (0x00007f9ccd9c1000) libm.so.11835d88 => not found libc.so.11835d88 => not found libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007f9ccd77e000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f9ccd540000) liblzma.so.5 => /usr/lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f9ccd31e000) libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f9ccd10e000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9cccf05000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9cccd01000) /lib64/ld-linux-x86-64.so.2 (0x00007f9cdf9a3000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f9cccad9000) 

Источник

Читайте также:  Nvidia geforce 210 linux driver

Got message unable to load shared object stats.so when R starts

I am using R-3.0.2 compiled from source code on Linux 64 and I got the following message when R starts:

Error in dyn.load(file, DLLpath = DLLpath, . ) : unable to load shared object '/home/hlfernandez/Eclipse/workspace/Bioscope/R/linux/x64/R-3.0.2/library/stats/libs/stats.so': libgfortran.so.3: cannot open the shared object file: No existe el archivo o el directorio Durante la inicialización - Mensajes de aviso perdidos package ‘stats’ in options("defaultPackages") was not found 

Does anybody have any idea about the source of the problem? It is rare that it says that the file or directory does not exist because it actually exists. My operating system is Kubuntu 13.10, maybe I have any missing library.

2 Answers 2

Somehow your system configuration or running environment has changed between the time you compiled R and the time you are using it, in particular the libgfortran.so.3 library is no longer discoverable. Likely if you do

$ R CMD ldd /path/to/R_HOME/library/stats/libs/stats.so 

you’ll get a list of successfully discovered link dependencies

linux-vdso.so.1 => (0x00007fff213ff000) libRlapack.so => /path/to/R_HOME/lib/libRlapack.so (0x00007fcafa557000) 

indicating that libgfortran.so.3 is not found. You could go looking for it

and then figure out what you’ve done to make it inaccessible to R (maybe ldconfig would be your friend). But libgfortran would most likely be in a standard location, so you’ve probably removed it in some other operation and need to reinstall it, or recompile R against the new location of libgfortran.

Specify the location of libgfortran using the system command ldconfig (sudo privileges required) or the environment variable LD_LIBRARY_PATH. But really these shouldn’t be necessary, libgfortan should have been installed using your OS package manager and in a way that does not require special additional configuration.

EDIT: I have discovered that putting the missing libraries in the directory R/lib solves the problem, thank you very much for the help!

If i run the ldd command I get:

bin/R CMD ldd ./library/stats/libs/stats.so /home/hlfernandez/Eclipse/workspace/Bioscope/R/linux/x64/R-3.0.2 linux-vdso.so.1 => (0x00007fff47dfe000) libRlapack.so => /home/hlfernandez/Eclipse/workspace/Bioscope/R/linux/x64/R-3.0.2/lib/libRlapack.so (0x00007fb595bb0000) libRblas.so => /home/hlfernandez/Eclipse/workspace/Bioscope/R/linux/x64/R-3.0.2/lib/libRblas.so (0x00007fb595983000) libgfortran.so.3 => not found libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb595665000) libR.so => /home/hlfernandez/Eclipse/workspace/Bioscope/R/linux/x64/R-3.0.2/lib/libR.so (0x00007fb5950c3000) libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007fb594eb4000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb594c97000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb5948ce000) libgfortran.so.3 => not found libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fb59468c000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fb594483000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb59427f000) /lib64/ld-linux-x86-64.so.2 (0x00007fb596205000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fb594056000) 

As you have said, there is a failure with libgfortran.so.3. ¿Is there a way to manually indicate where the libgfortran3.so file is located?

Источник

Оцените статью
Adblock
detector