Re: dynamic static linking library --

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Tue, Dec 16, 2008 at 11:54 AM, nidhi mittal <nidhimittal19@xxxxxxxxx> wrote:
hi all i know its not directly related to kernel ...but its the doubt i got while kernel programming only ..its in c langugage
it wd be kind if you accept this ques and answer it
i have a doubt regarding linking of libraries in c program
lets say i have a hello.c C program and hello is executable file correspoding to this.

i read that if libraries are linked dynamically then size of executable file hello is smaller as compared to the size of executable if libararies are linked statically .
in my opinion that means that in case of dynamic linked library hello does not contain libraries with it it is just linked with them.
when you compile your executable you need to link it to already existing module with something like
gcc  -l"name" -L"path_of_lib" filename.c -o filename.bin

For loading symbol from library you can use dlopen() and dlsym() calls.


may be hello contain references to symbols ...where they are present in linked libraries.

now suppose i transfer this hello file to some other machine but same platform which doesnt contain these libraries ....will it work there ?
i hope it shd not
but i have heard ppl say that executable file is complete in itself and it works taken anywhere on same platform.
It wont run, typically for any symbol to get resolve the lib should be installed on the target machine. Executables also have many formats. look for them.


pl clarify ..
where i m wrong i know there is some fault in my understanding of linking concept but unable to clarify it from google...
You haven't googled properly.

Suggested reading:
man dlopen, man dlsym, man ldconfig. Richard steven Advance unix programming.
do some googling for shared lib on linux.

--
Thanks & Regards
Nidhi

-Anuz

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux