Possible to statically link shared object libraries?
Asked Answered
C

1

1

I'm building a library that needs to be dynamically linked to my project. The output is a .so file, so I think I'm on the right track. I'm concerned by the way it's being linked at compile time - by specifying the location of its makefile and depending on a bunch of macros, which I've never encountered before.

Can I assume that since I'm building a .so library (rather than a .a) that I'm in fact dynamically linking? Or is it possible for .so libs to be statically linked, in which case I need to rip apart the make/config files to better understand what's going on?

Thanks,

Andrew

Cosecant answered 13/12, 2010 at 15:52 Comment(0)
V
0

I'm not familiar with internal structure of executables and shared objects, so I could only give some practical hints.

Assuming you use gcc, it should have -shared option when linking object files into library - this way ld (called by gcc) makes shared object instead of executable binary.

gcc -shared -o libabc.so *.o ...

When you link some application with this libabc.so it should link without errors and after that with ldd command you should be able to see libabc.so among its dependencies.

$ ldd app
    ...
    libabc.so => ...............
Veliavelick answered 14/12, 2010 at 10:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.