I have the header files of a shared library but not the shared library nor its source code.
Can I still compile some code against this library?
If not, what information does the shared library contain which is not in the headers?
Can I still compile some code against this library?
Compile: yes. Link: maybe.
You can create a dummy library to link against. E.g. if the header contains:
int library_func(void*);
then:
// dummy_lib.c
int library_func(void *p) { return 0; }
gcc -fPIC -shared -o libfoo.so dummy_lib.c
# Now you can use libfoo.so to link your program.
There are some gotcha's:
SONAME
of something other than libfoo.so
(e.g. libfoo.so.2
). There is no way for you to know without access to the real libfoo
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With