[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
linking modules into programs problem
From: |
Nick Hudson |
Subject: |
linking modules into programs problem |
Date: |
Thu, 15 Mar 2001 16:39:56 +0000 |
KDE2 has a habit of creating modules and then linking them into
programs. Now this isn't a problem if the modules are named libNAME.la,
but if they are named NAME.la then I see build errors on NetBSD/a.out.
I've attached a simplified exmaple from each of NetBSD/ELF and
NetBSD/a.out.
My main question is
- should libtool allow this or insist that when linking modules
into programs libNAME.la should be used, or
- should libtool be fixed to produce the right results for the
a.out case
Nick
--
aka address@hidden, address@hidden
$ echo "#include <stdio.h>\nint main() { printf(\"hello world\\\\n\"); }" >
main.c
$
$ libtool --mode=compile cc -c main.c
mkdir .libs
cc -c main.c -fPIC -DPIC -o .libs/main.o
cc -c main.c -o main.o >/dev/null 2>&1
$
$ libtool --mode=link cc -o module.la main.lo -avoid-version -module -rpath
`pwd`/inst
cc -shared .libs/main.o -Wl,-soname -Wl,module.so -o .libs/module.so
ar cru .libs/module.a main.o
ranlib .libs/module.a
creating module.la
(cd .libs && rm -f module.la && ln -s ../module.la module.la)
$
$ echo "" > dummy.c
$
$ cc -c dummy.c
$
$ libtool --mode=link cc -o prog dummy.o module.la
>
cc -o .libs/prog dummy.o ./.libs/module.so -Wl,--rpath -Wl,/tmp/test/inst
creating prog
$
$ ./prog
hello world
$
$ libtool --mode=execute ldd prog
/tmp/test/.libs/prog:
module.so => /tmp/test/./.libs/module.so
-lc.12 => /usr/lib/libc.so.12
$
$ libtool --mode=install install module.la `pwd`/inst
install .libs/module.so /tmp/test/inst/module.so
install .libs/module.lai /tmp/test/inst/module.la
install .libs/module.a /tmp/test/inst/module.a
ranlib /tmp/test/inst/module.a
chmod 644 /tmp/test/inst/module.a
----------------------------------------------------------------------
Libraries have been installed in:
/tmp/test/inst
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
$
$ libtool --mode=install install prog `pwd`/inst
install .libs/prog /tmp/test/inst/prog
$
$ ldd inst/prog
inst/prog:
module.so => /tmp/test/inst/module.so
-lc.12 => /usr/lib/libc.so.12
$
$ echo "#include <stdio.h>\nint main() { printf(\"hello world\\\\n\"); }" >
main.c
$
$ libtool --mode=compile cc -c main.c
mkdir .libs
cc -c main.c -fPIC -DPIC -o .libs/main.o
cc -c main.c -o main.o >/dev/null 2>&1
$
$ libtool --mode=link cc -o module.la main.lo -avoid-version -module -rpath
`pwd`/inst
/usr/bin/ld -Bshareable -o .libs/module.so .libs/main.o
ar cru .libs/module.a main.o
ranlib .libs/module.a
creating module.la
(cd .libs && rm -f module.la && ln -s ../module.la module.la)
$
$ echo "" > dummy.c
$
$ cc -c dummy.c
$
$ libtool --mode=link cc -o prog dummy.o module.la
cc -o .libs/prog dummy.o -L./.libs -lmodule -R/tmp/test/inst
ld: -lmodule: no match
collect2: ld returned 1 exit status
$
$ cc -o .libs/prog dummy.o `pwd`/.libs/module.so
$
$ ldd .libs/prog
.libs/prog:
./.libs/module.so (0x40019000)
-lc.12 => /usr/lib/libc.so.12.40.2 (0x4002a000)
$
$ ./.libs/prog
hello world
$
- linking modules into programs problem,
Nick Hudson <=
- Re: linking modules into programs problem, Nick Hudson, 2001/03/19
- Re: linking modules into programs problem, Michael Matz, 2001/03/19
- Re: linking modules into programs problem, Christoph Pfisterer, 2001/03/19
- Re: linking modules into programs problem, Michael Matz, 2001/03/19
- Re: linking modules into programs problem, Alexandre Oliva, 2001/03/20
- Re: linking modules into programs problem, Nick Hudson, 2001/03/23
- Re: linking modules into programs problem, Michael Matz, 2001/03/28
- Re: linking modules into programs problem, Nick Hudson, 2001/03/28