libtool and shared libraries with static library references

libtool and shared libraries with static library references

Post by David Lee Ludwi » Fri, 27 Oct 2000 04:00:00



I'm trying to build a shared (dlopen-able) library which uses code from a
static library, however I'm running into problems.  More specifically...

I am using autoconf+automake+libtool to build a shared library which will
eventually be dlopen()ed by another program.  This shared library needs
to use libpci, which is installed as a static library
(/usr/lib/libpci.a).

The shared library will get built (with a warning, listed later in this
message), however when I try to dlopen it, I get the following error
message:

../modules/LinuxPCIBus/.libs/libdckbase_linuxpcibus.so: undefined
symbol: pci_read_bytedck_shutdown

I'm guessing that libpci never gets properly linked.

In addition, I also get the following warning when I try to build the
shared library.  Note, here I am using "-lpci" to reference libpci.

*** Warning: This library needs some functionality provided by -lpci.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.

When trying to link in libpci directly (by replacing "-lpci" with
"/usr/lib/libpci.a"), I get the following compile-time message:

libtool: link: cannot build libtool library `libdckbase_linuxpcibus.la'
from non-libtool objects: /usr/lib/libpci.a

Any ideas on how I would go about fixing this?

Additional notes:

* The shared library is built using the following automake code:

--< cut here >--

lib_LTLIBRARIES = libdckbase_linuxpcibus.la

libdckbase_linuxpcibus_la_SOURCES = \
        pci_info.c \
        LinuxPCIBus.cxx

libdckbase_linuxpcibus_la_LIBADD = -lpci

--< cut here >--

--
David Ludwig               | "The Linux philosophy is laugh in the face of
davidl<at>wpi.edu          | danger.  Oops.  Wrong One.  'Do it yourself.'
http://www.wpi.edu/~davidl | That's it."                  - Linus Torvalds

 
 
 

1. Using libtool to build shared libraries that depend on static libraries

I'm trying to link an object file and a static library into a shared
library.  I can easily do this with gcc, but now I would like to use libtool
for more portability.  But, libtool gives me an error like this when I try
to link:

*** Warning: This library needs some functionality provided by -lplugin.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: libtool could not satisfy all declared inter-library
*** dependencies of module libsyncmal.  Therefore, libtool will create
*** a static module, that should work as long as the dlopening
*** application is linked with the -dlopen flag.

Bummer.  I tried following the advice of the first warning, and created a
shared version of the static library.  I thought I had succeeded when
libtool produced a shared library, but the shared library produced depended
on the shared version of the static library.  Not what I wanted.

Can libtool do this?  Any help would be greatly appreciated.  I can post a
snapshot of the code on my website if that would help.

Thanks,
Jason
--
Jason Day                                       jasonday at
http://jasonday.home.att.net                    worldnet dot att dot net

"Of course I'm paranoid, everyone is trying to kill me."
    -- Weyoun-6, Star Trek: Deep Space 9

2. Newbie try to setup gnome 2

3. Compiling static libraries as shared libraries

4. Having problems with DNS Server (named)

5. Building shared library which includes static libraries

6. FTP and Mindspring

7. Can a static library be compiled into a shared library?

8. Creating disk images under Linux

9. Converting a Static Library to a Shared Library

10. Building shared libraries that contain static libraries.

11. Using static libraries and shared libraries in same program?

12. link static libraries into a shared library

13. how do I find out what shared libraries and static libraries a program depends on?