开发者

incorporate .so into another .so without dependency?

i have a c program that relies on a second library whose compilation i ca开发者_Python百科n control. i want to be able to compile my program into a shared object library without it linking to the second library. in other words i want a single monolithic shared object library at the end. how can i do this?

if i separately compile the second library into a .so and include that as a dependency when compiling my program, i can see that i need that file when i run ldd on the binary.


You need to compile your second library as a .a (static library) and statically link that into your c program.

Static linking is when object files are linked at compile time and are part of the final binary, the resulting executable can be executed with no dependencies..

Shared libraries (.so) are linked at run time and must be available when you execute the binary that links them.

the gcc flag to link statically is: -static this will automatically search for .a files.


What radman said above.

http://www.network-theory.co.uk/docs/gccintro/gccintro_25.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜