Reputation: 531
Let's say I have 3 files main.c
, mylib.h
and mylib.c
.
main.c:
#include <stdio.h>
#include "mylib.h"
int main(int argc, char **argv) {
printf("%d\n", foo());
}
mylib.h:
#pragma once
int foo();
mylib.c:
#include "mylib.h"
int foo() { return 5; }
If I build mylib
as dynamic library and link it to main
, main
will have dynamic reference to it:
>>> ldd main
...
libmylib.so => /some_path/libmylib.so
...
I found out if I change mylib.c
, rebuild mylib
and foo
symbol address will change, I don't need to rebuild / link again my main
program.
Does symbol lookup happen in runtime as if I loaded library using dlopen
and no external symbol addresses are stored in main
program?
Upvotes: 0
Views: 90
Reputation: 222224
Does symbol lookup happen in runtime as if I loaded library using
dlopen
and no external symbol addresses are stored inmain
program?
Yes.
Upvotes: 1