所以到不依赖其他的

所以到不依赖其他的

本文介绍了结合。所以到不依赖其他的.so?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有依赖于第二个库的编辑,我可以控制的C程序。我希望能够编译我的程序到一个共享对象库中没有它链接到第二个库。换句话说,我希望在最后一个单片共享对象库。我怎样才能做到这一点?

i have a c program that relies on a second library whose compilation i can 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?

如果我单独第二个库编译成一个.so和包括作为一个依赖我的编译程序的时候,我可以看到我需要的文件时,我对二进制运行LDD。

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.

推荐答案

您需要编译你的第二个库以.a(静态库)和静态链接到你的C程序。

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..

共享库(.so)在运行时相连,当执行一个链接它们的二进制文件必须是可用的。

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

在gcc标志静态链接为: -static 这会自动搜索.a文件

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

这篇关于结合。所以到不依赖其他的.so?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 01:20