dynamic linking

dynamic linking

Post by Michael P. Souli » Fri, 03 Dec 1999 04:00:00



        Hello. I've been wondering, are there code changes required to make
use of dynamic linking with a shared library, or is it merely linker
magic? I didn't see this specifically in the FAQ. If I wanted to compile
with dynamic linking, where I would normally put -llib for lib<lib>.a, what
do I specify to gcc to tell it that I want to link dynamically?

        Thanks,

        Mike

--

--------------------------------------
The day that Microsoft makes something that doesn't suck is the
day that they make a vacuum cleaner.
                -- Anonymous

 
 
 

dynamic linking

Post by Anthony Jenkin » Sat, 04 Dec 1999 04:00:00



>         Hello. I've been wondering, are there code changes required to make
> use of dynamic linking with a shared library, or is it merely linker
> magic? I didn't see this specifically in the FAQ. If I wanted to compile
> with dynamic linking, where I would normally put -llib for lib<lib>.a, what
> do I specify to gcc to tell it that I want to link dynamically?

gcc -shared -o bar -lfoo bar.c

You might look into GNU libtool, which hides the platform dependencies of
building a dynamically-linked executable (``info libtool'').

Quote:> The day that Microsoft makes something that doesn't suck is the
> day that they make a vacuum cleaner.
>                 -- Anonymous

HAHA!  I *love* that quote!

--
Anthony Jenkins
aka Scoobi_FreeBSD at http://chat.yahoo.com , Computer sections
http://www.mindspring.com/~abjenkins
------
Doh - Homer Simpson

 
 
 

dynamic linking

Post by Priya Bathij » Sat, 04 Dec 1999 04:00:00


You don't need to do anything special.
All linkers would first look for _lib<lib>.so_ and then if _not_ found
then look for lib<lib>.a

As long as your .so file is created, the linker should not need any
further info. (in fact, if you have both .so and .a libs, and you want to
use only the static lib (??) , then you would have to do something
special and would have to use the -Bstatic option.)

As long as you have compiled with "-Kpic" flag and have linked with
"-dy" , you should be fine..

Priya

:-)     Hello. I've been wondering, are there code changes required to make
:-)use of dynamic linking with a shared library, or is it merely linker
:-)magic? I didn't see this specifically in the FAQ. If I wanted to compile
:-)with dynamic linking, where I would normally put -llib for lib<lib>.a, what
:-)do I specify to gcc to tell it that I want to link dynamically?
:-)
:-)     Thanks,
:-)
:-)     Mike
:-)
:-)
:-)

--
Priya

 
 
 

dynamic linking

Post by Bryan VanDeVe » Tue, 07 Dec 1999 04:00:00



> You don't need to do anything special.
> All linkers would first look for _lib<lib>.so_ and then if _not_ found
> then look for lib<lib>.a

> As long as your .so file is created, the linker should not need any
> further info. (in fact, if you have both .so and .a libs, and you want to
> use only the static lib (??) , then you would have to do something
> special and would have to use the -Bstatic option.)

> As long as you have compiled with "-Kpic" flag and have linked with
> "-dy" , you should be fine..

I believe the original poster was asking about shared lib creation using
gcc, those commands look more appropriate for Sun's cc or the HP-UX
compiler.  At any rate, for gcc, compile the object files for shared
libs with "-fpic" and link with "-shared"  (assuming a relatively recent
version, since 2.8.1 or so)

Regards,

--
Bryan Van de Ven
Applied Research Labs
University of Texas, Austin

 
 
 

dynamic linking

Post by t.. » Wed, 08 Dec 1999 04:00:00


Slightly different topic...

I am planning to convert a bunch of ancient apps and static libraries
to use dynamic linking. Is there any watch-out I should be aware of ?

Thanks for any suggestions.
Thanh

In article <Pine.SO4.4.05.9912031654160.20391-


> You don't need to do anything special.
> All linkers would first look for _lib<lib>.so_ and then if _not_
found
> then look for lib<lib>.a

> As long as your .so file is created, the linker should not need any
> further info. (in fact, if you have both .so and .a libs, and you
want to
> use only the static lib (??) , then you would have to do something
> special and would have to use the -Bstatic option.)

> As long as you have compiled with "-Kpic" flag and have linked with
> "-dy" , you should be fine..

> Priya

> :-)        Hello. I've been wondering, are there code changes required to
make
> :-)use of dynamic linking with a shared library, or is it merely
linker
> :-)magic? I didn't see this specifically in the FAQ. If I wanted to
compile
> :-)with dynamic linking, where I would normally put -llib for
lib<lib>.a, what
> :-)do I specify to gcc to tell it that I want to link dynamically?
> :-)
> :-)        Thanks,
> :-)
> :-)        Mike
> :-)
> :-)
> :-)

> --
> Priya

Sent via Deja.com http://www.deja.com/
Before you buy.
 
 
 

dynamic linking

Post by Michael P. Souli » Mon, 13 Dec 1999 04:00:00




Quote:>I believe the original poster was asking about shared lib creation using
>gcc, those commands look more appropriate for Sun's cc or the HP-UX
>compiler.  At any rate, for gcc, compile the object files for shared
>libs with "-fpic" and link with "-shared"  (assuming a relatively recent
>version, since 2.8.1 or so)

        Cool. Thanks very much. I'll see if I can get that to work.

        Mike

--

--------------------------------------
Ryan's Law:
        Make three correct guesses consecutively
                and you will establish yourself as an expert.