Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 499
user918545 Avatar asked Nov 13 '22 18:11

user918545


1 Answers

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.

like image 116
nobsid Avatar answered Nov 16 '22 06:11

nobsid