Linux install shared library

How to install a shared library on Ubuntu Linux?

Solution 1: Depending on library, ubuntu stores its libraries mainly in three locations /lib /usr/lib /usr/local/lib Following is from File System Hierarchy Standard /lib /usr/lib /usr/local/lib contains local libraries i.e one specific for this system but I can not find references to /usr/local/lib in FHS, it only contains explanation for /usr/local. I’m having trouble shared libraries on my Ubuntu 10.04.

How to install a shared library on Ubuntu Linux?

I’m having trouble shared libraries on my Ubuntu 10.04. I expirienced it several times in the last months, read a lot about installing libs but I seem to miss the point.

Starting with the source code directory, I run the following commands:

  1. make
    Runs clean, without any error
  2. sudo make install
    Seems to be working fine, ends with: cp foo.so.0.1 /usr/local/lib/
    rm -f /usr/local/lib/foo.so
    ln -s /usr/local/lib/foo.so.0.1 /usr/local/lib/foo.so
  3. sudo ldconfig
    Runs without any output

When writing a makefile, I can not address the lib by its name, but by its path:
Not working: -lfoo
Working: -L/usr/local/lib/foo.so

The problem stays the same, no matter what lib I try to install.

What am I missing here? Or what can I do to find out?

Is /usr/local/lib/ in your library search path? If not you will need to specify both -lfoo and /usr/local/lib/ in your Makefile, so the linker knows where to look.

Whether or not /usr/local/lib/ is in your library search path is dependent on your distribution.

Remember that the library names should start with lib and end with .so . Maybe you are missing the starting lib

Where does Ubuntu look for shared libraries?, ldconfig creates, updates, and removes the necessary links and cache (for use by the run-time linker, ld.so) 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 (/usr/lib and /lib). ldconfig checks the header and file names of the libraries it

Ubuntu: Where does Ubuntu look for shared libraries?

Ubuntu : Where does Ubuntu look for shared libraries ?Helpful? Please support me on Patreon: https://www.patreon.com/roelvandepaarWith thanks & praise to God,

Where does Ubuntu store its library files?

I want to add my own library to use in c compiling, but don’t really know where ubuntu stores it.

Depending on library, ubuntu stores its libraries mainly in three locations

Читайте также:  Release renew для linux

Following is from File System Hierarchy Standard

The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin.

/usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts. [22]

Applications may use a single subdirectory under /usr/lib. If an application uses a subdirectory, all architecture-dependent data exclusively used by the application must be placed within that subdirectory.

/usr/local/lib contains local libraries i.e one specific for this system but I can not find references to /usr/local/lib in FHS, it only contains explanation for /usr/local.

Based on your comments to your question, I think what you are really asking is «How do I install a custom library I wrote and where should I put it?»

In general, things built locally for others on the machine to user are put into the /usr/local tree. The header file should go into /usr/local/include. The compiled library should go into /usr/local/lib. The .c file is not part of the library, it is part of the source and not something normally not installed for the use of the end user. You will need root access to put files in either of these locations.

To build the library, you will need to build first decide if you want a static or dynamic (shared) library. More information on creating a shared library can be foundin section 3.4, Creating a Shared Library at http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html. (They also have recommendation about where to put stuff — most developers will have an an opinion or three 🙂 )

Ubuntu follows Filesystem Hierarchy Standard (http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard), regular applications libraries should be stored under /usr/lib .

Please note that developing/managing libraries is not a trivial subject, you should read some more detailed documentation, here is a nice tutorial: http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

You should tell the compiler, where it can find your library. Assumed, the path to your library is «/path/to/lib/libfoo.a», you could compile and link your program «hello.c» like this:

gcc -L/path/to/lib -lfoo hello.c 

This is not specific to Ubuntu, actually all C-compilers I know support those flags.

How to install a shared library on Ubuntu Linux?, I’m having trouble shared libraries on my Ubuntu 10.04. I expirienced it several times in the last months, read a lot about installing libs but I seem to miss the point. Starting with the source code directory, I run the following commands: Look for packages libboost-dev, or libboost-all-dev. No need to install them manually …

How to install shared libraries

I have a problem with Cisco PacketTracer

wolf@linux:/opt/pt/bin$ ./PacketTracer7 ./PacketTracer7: error while loading shared libraries: libQt5WebEngineWidgets.so.5: cannot open shared object file: No such file or directory wolf@linux:/opt/pt/bin$ 

It turns out that some of the libraries are not there:

wolf@linux:/opt/pt/bin$ ldd PacketTracer7 | grep not libQt5WebEngineWidgets.so.5 => not found libQt5WebEngineCore.so.5 => not found libQt5Script.so.5 => not found libQt5ScriptTools.so.5 => not found wolf@linux:/opt/pt/bin$ 

I’ve tried to install it, but it didn’t work:

wolf@linux:/opt/pt/bin$ sudo apt install libQt5WebEngineWidgets.so.5 libQt5WebEngineCore.so.5 libQt5Script.so.5 libQt5ScriptTools.so.5 Reading package lists. Done Building dependency tree Reading state information. Done E: Unable to locate package libQt5WebEngineWidgets.so.5 E: Unable to locate package libQt5WebEngineCore.so.5 E: Unable to locate package libQt5Script.so.5 E: Unable to locate package libQt5ScriptTools.so.5 wolf@linux:/opt/pt/bin$ 

I’ve also tried to change it to lower case and remove .so.5 from the name, but it still didn’t work.

sudo apt install libQt5WebEngineWidgets.so libQt5WebEngineCore.so libQt5Script.so libQt5ScriptTools.so sudo apt install libQt5WebEngineWidgets libQt5WebEngineCore libQt5Script libQt5ScriptTools sudo apt install libqt5webenginewidgets libqt5webenginecore libqt5script libqt5scripttools 

What is the right way to do this?

Читайте также:  What is cpu usage in linux

This will install the first two libraries which are libQt5WebEngineWidgets.so.5 & libQt5WebEngineCore.so.5, but not the last two:

sudo apt install libqt5webenginewidgets5 libqt5webenginecore5 

Two more libraries to be installed:

wolf@linux:/opt/pt/bin$ ldd ./PacketTracer7 | g not libQt5Script.so.5 => not found libQt5ScriptTools.so.5 => not found wolf@linux:/opt/pt/bin$ 

The library’s name must be correct; it’s case sensitive too. Try this:

sudo apt install libqt5webenginewidgets5 libqt5webenginecore5 libqt5script5 libqt5scripttools5 

Also, use the shell script provided. Do not run the ELF file directly. That won’t work.

sudo apt install libqt5webenginecore5 libqt5webenginewidgets5 libqt5script5 libqt5scripttools5 

It will pull a few more packages along.

I’ve used apt-cache to find those, for example, here are the first two

~$ apt-cache search libQt5Script libqt5script5 - Qt 5 script module libqt5scripttools5 - Qt 5 script tools module 
~$ apt-cache search libQt5Script libqt5script5 - Qt 5 script module libqt5scripttools5 - Qt 5 script tools module 

You can also combine two search words

apt-cache search 'libQt5WebEngine|libQt5Script' 

Lastly, there is a searchable package database at https://packages.ubuntu.com/.

Ubuntu: Where does Ubuntu look for shared libraries?, Ubuntu : Where does Ubuntu look for shared libraries ?Helpful? Please support me on Patreon: https://www.patreon.com/roelvandepaarWith thanks & praise to God,

How do I get Ubuntu to look somewhere for library files?

I have installed OpenMPI and a package called CVODE onto my Ubuntu system, which is running in a virtual machine (using VirtualBox). There was one problem which was worked around by copying some library files to /usr/lib . In other words, the following happened when I tried the example programs that came with CVODE:

$ mpirun ./cvAdvDiff_bnd cvAdvDiff_bnd: error while loading shared libraries: libsundials_cvode.so.1: cannot open shared object file: No such file or directory $ sudo cp /home/jeff/sundials/instdir/lib/libsundials_cvode.so.1 /usr/lib/libsundials_cvode.so.1 $ mpirun cvAdvDiff_bnd cvAdvDiff_bnd: error while loading shared libraries: libsundials_nvecserial.so.0: cannot open shared object file: No such file or directory $ sudo cp /home/jeff/sundials/instdir/lib/libsundials_nvecserial.so.0 /usr/lib/libsundials_nvecserial.so.0 $ mpirun cvAdvDiff_bnd 2-D Advection-Diffusion Equation Mesh dimensions = 10 X 5 Total system size = 50 Tolerance parameters: reltol = 0 abstol = 1e-05 At t = 0 max.norm(u) = 8.954716e+01 At t = 0.10 max.norm(u) = 4.132889e+00 nst = 85 At t = 0.20 max.norm(u) = 1.039294e+00 nst = 103 At t = 0.30 max.norm(u) = 2.979829e-01 nst = 113 At t = 0.40 max.norm(u) = 8.765774e-02 nst = 120 At t = 0.50 max.norm(u) = 2.625637e-02 nst = 126 At t = 0.60 max.norm(u) = 7.830425e-03 nst = 130 At t = 0.70 max.norm(u) = 2.329387e-03 nst = 134 At t = 0.80 max.norm(u) = 6.953434e-04 nst = 137 At t = 0.90 max.norm(u) = 2.115983e-04 nst = 140 At t = 1.00 max.norm(u) = 6.556853e-05 nst = 142 Final Statistics: nst = 142 nfe = 174 nsetups = 23 nfeLS = 0 nje = 3 nni = 170 ncfn = 0 netf = 3 

The problems finding those two files were solved by copying them to /usr/lib . However, there are hundreds of files in ~/sundials/instdir/lib/ .

Читайте также:  Восстановление linux после windows

How can I get Ubuntu to look for those files in their current location instead of copying them all to /usr/lib/ ?

Use the LD_LIBRARY_PATH or LD_PRELOAD environment variables, documented in man ld.so .

10.10 — Where does Ubuntu store its library files?, The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin. /usr/lib /usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts. [22]

Источник

Andrew Beacock’s Blog

Sometimes in Linux when you install a new software package the instructions tell you to add a directory of shared libraries to your $LD_LIBRARY_PATH environment variable in your .bashrc.

You may have noticed that if you then create a shortcut icon on your desktop to this application it won’t start because it can’t find the libraries.
A typical solution is to write a wrapper shell script to set the LD_LIBRARY_PATH and then call that application.

Well, I’ve discovered how to add them to your system’s library path allowing all environments to access them. Note: There are differences between Debian and Ubuntu (the two flavours of Linux that I’m familiar with).

Ubuntu
Create a new file in /etc/ld.so.conf.d/ called .conf

Edit the file and add a line per directory of shared libraries (*.so files), it will look something like:

Debian
Edit /etc/ld.so.conf

Add a line per directory of shared libraries (*.so files) to the bottom of the file, it will look something like:

/usr/X11R6/lib
/usr/lib/APPLICATION/lib

If you run your new application it should now work fine without you having to set any LD_LIBRARY_PATH environment variables.
If you still have problems you can obtain a list of the libraries that are on the system path by re-running the ldconfig command in verbose mode:

  • Get link
  • Facebook
  • Twitter
  • Pinterest
  • Email
  • Other Apps

Источник

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