I have a .so
library and while building it I didn't get any undefined reference errors.
But now I am building an executable using the .so
file and I can see the undefined reference errors during the linking stage as shown below:
xy.so: undefined reference to `MICRO_TO_NANO_ULL'
I referred to this and this but couldn't really understand the dynamic linking.
Also reading from here lead to more confusion:
Dynamic linking is accomplished by placing the name of a sharable library in the executable image. Actual linking with the library routines does not occur until the image is run, when both the executable and the library are placed in memory. An advantage of dynamic linking is that multiple programs can share a single copy of the library.
My questions are:
Doesn't dynamic linking means that when I start the executable using
./executable_name
then if the linker not able to locate the.so
file on which executable depends it should crash?What actually is dynamic linking if all external entity references are resolved while building? Is it some sort of pre-check performed by dynamic linker? Else dynamic linker can make use of
LD_LIBRARY_PATH
to get additional libraries to resolve the undefined symbols.