Re: :dll and linking to other libraries

Magnus Therning <[email protected]> Sun, 25 Jul 2004 16:56:02 +0200
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
On Sun, Jul 25, 2004 at 04:05:01PM +0200, Bram Moolenaar wrote:
>
>Magnus Therning wrote:
>
>> I have the following rule:
>> 
>>  :dll sqlite : $sqlite_source
>>  :attr { add_LIBS = -ltcl -lm -ldl } $(DLLPRE)sqlite$(DLLSUF)
>> 
>> But the resulting shared lib isn't linked to any of the libraries:
>> 
>>  $ ldd libsqlite.so
>>          statically linked
>> 
>> Why is it like this?
>
>I don't understand your "ldd" command.  It should be used on a program
>to show what libraries it uses.  I don't think it makes sense using it
>on a library.

Yes, it does. At least on Linux:

 $ ldd /usr/lib/libtcl8.3.so
		libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x4008e000)
	libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x40091000)
	libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x400b5000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

>I also don't understand the intention of using the add_LIBS attribute
>on the shared library.  Do you want to build the shared library with
>these libs?  Then putting this in the :dll command might work better.

Do you mean that I shouldn't use :attr the way I have? I put it on a
separate line to make things a little more readable.

Yes, I want to make use of the ability for ELF shared libraries to
themselves being linked to shared libraries. Then I can do the following
linkage:

 sqlite3 linked with libsqlite.so
 libsqlite.so linked with libtcl.so libm.so

This way anyone that creates an executable that is linked to
libsqlite.so won't need to bother about libtcl.so and libm.so.

I think I found the problem. The :dll rule results in a link command
like this:

 ld -shared -o $(target) $(source)

if the link command would be:

 gcc -shared -o $(target) $(source)

then it would work as I expected it to. Also, I don't know what variable
is used to get the link command for :dll rules (it isn't $LD AFAIK).

/M

-- 
Magnus Therning                    (OpenPGP: 0xAB4DFBA4)
[email protected]
http://magnus.therning.org/

People who don't make mistakes make the greatest mistake of all;
they do nothing.
     -- Unknown
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBA8oCiMWTaatN+6QRAhohAJ9bByyTjnQ5SY9Krq8rKe5oZssfggCfdyYI
Wy+RRKlf+8Bewafe83MEmKM=
=gSoL
-----END PGP SIGNATURE-----