You generally cannot link a static library into a shared one.
Because static libraries (lib*.a
) don't contain position-independent code (PIC), but shared libraries need PIC (in practice).
(in theory, non PIC shared libraries could be possible; but they would contain so much relocation that the "shared" aspect is lost and the dynamic linker would have a lot of work. So in practice, every shared library needs to be PIC to permit its code segment[s] to be mmap(2)-ed at different addresses in various processes and still stay shared)
Read Drepper's How To Write Shared Libraries paper.
However, you can link a shared library (e.g. libopenmp.so
) into another one (your shared library, see this). Then the program using your shared library will need that libopenmp.so
.
So you could do 2 or 3, or even package your library as a proper .deb
package (which would depend on libopenmpi2
Debian package).
You may want to understand package management.
You should understand more the virtual address space of your process. For that, use proc(5) and pmap(1). For first examples, try cat /proc/self/maps
and cat /proc/$$/maps
. Then, if your process has pid 1234, try cat /proc/1234/maps
and/or pmap 1234
. You'll then understand how shared libraries are mmap(2)-ed.