如何静态链接复杂程序 [英] How to statically-link a complex program

查看:64
本文介绍了如何静态链接复杂程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中,下载了程序源并希望将其静态链接. 那里有一个很大的Makefile, 我

In Linux, downloaded a program source and want it to be statically linked. Have a huge Makefile there, I

./configure
make

进行编译. 预想这有点太笼统了,但是如何使二进制文件静态链接?

to compile. prehpes it's a bit too general to ask, but how can I make the binary statically linked?

这样做的原因是要确保二进制文件将 没有依赖关系(或至少尽可能少),因此可以在任何基于Linux的计算机上运行,​​甚至可以在没有Internet连接和未更新的Linux上运行.

the reason for this is wanting to make sure the binary will have no dependencies (or at least as few as possible), making it possible to run on any Linux based computer, even one without Internet connection, and non-updated Linux.

推荐答案

大多数autoconf生成的configure脚本将允许您进行静态构建:

Most autoconf generated configure script will allow you to make a static build:

 ./configure --enable-static
 make

如果这不起作用,则可以通过LDFLAGS传递链接器标志,如下所示:

If that doesn't work, you may be able to pass linker flags in via LDFLAGS, like this:

 ./configure LDFLAGS=-static

这篇关于如何静态链接复杂程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆