Question

A have a project build with GNU autotools. Now I have a tiny change and only want to copy one single library libmylib.so and one program myprog.x (using that library) from the whole collection.

I do not want to use make install because I have to be very careful not to overwrite all the other stuff.

When I do

ldd .libs/myprog.x

I see that the library used is -- as expected -- the freshly built library and not that one in /usr/lib/.

$ ldd .libs/myprog.x
libmylib.so.0 => /home/user/project/.libs/libmylib.so.0 (0x003bb000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00f57000)
libc.so.6 => /lib/tls/libc.so.6 (0x00948000)
libz.so.1 => /usr/lib/libz.so.1 (0x0024e000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00ee7000)

How can I tell make or libtool to relink myprog.x so that I can copy it manually to /usr/bin/? After copying libmylib.so to /usr/lib/ of course.

Was it helpful?

Solution

(I worked this out by running make -n install | less.)

You probably want to install the libraries and program (if it's linked using libtool) with libtool, so try something like:

sudo ./libtool --mode=install /usr/bin/install -c libmylib.la /usr/lib
sudo ./libtool --mode=install /usr/bin/install -c myprog.x /usr/bin

Libtool might ask you to run a ./libtool --mode=finish command as well. I'd trust its advice. Before doing any of this, I'd run the commands with the --dry-run option and without sudo to see what exactly is going to happen.

Note that I'm not running the system libtool, but the one that was created by the configure script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top