I have a shared library librun.so without source code, but have an SDK to work with it.
How generate static library (librun.a) with only export functions from librun.so for dynamic linking my library libapp.so with librun.so?
On windows it's done like this, but on Linux how?
- dumpbin /exports run.dll
- Make run.def with export functions
- lib /def:run.def /out:run.lib /machine:x86
On Linux you normally don't need explicit static library and just link against shared library directly:
$ gcc ... -o libapp.so -Lpath/to/librun.so -lrun
If you really need an static library, you can generate it via Implib.so:
# Generate wrappers
$ implib-gen.py librun.so
Generating librun.so.tramp.S...
Generating librun.so.init.c...
# Create static library
$ gcc -c -fPIC librun.so.tramp.S librun.so.init.c
$ ar rcs librun.a librun.so.*.o
Note that resulting static library librun.a
will be a wrapper which internally loads original librun.so
and forwards calls to it (this is same as Windows).