|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
What happens when linking and execution?
Let's say I have a shared library (libmyFile1.so) that contains a
function myFunc1 and it is called by a application myApp1. I build and link the application cc -o myApp1 myApp1.o -L/usr/source/lib -lmyFile1 Question 1 What does this linking actually do? Does it copy the location of myFunc1 within the libmyFile1.so? I know if doesn't copy the actual code from the shared library unless I am linking statically. This leads me to my next question. Lets say I make numerous changes to the underlying code within libmyFile1.so, but no changes to the function name myFunc1 or any changes to the parameters. Question 2 Can I not just replace libmyFile1.so with a newly rebuilt one without having to relink or rebuild the original application? Is there any scenario where only the underlying code is modified that would require a rebuild or relink of the application? [1: ELF linkers just note the names of the symbols to be resolved and the places in the executable where they're referenced. The actual locations are resolved at dynamic link time when the executable starts. 2: So long as the interfaces don't change, i.e., number and types of arguments, you should be able to build a new library and just use it. If you change the code so that, e.g., an int argument changes to float, you'll have to rebuild both sides. See my book for more info. -John] |
![]() |
| Viewing: Web Development Archives > FAQs > Compilers > What happens when linking and execution? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|