如何静态链接使用 ./configure 的 Linux 软件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20068947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to static link Linux software that uses ./configure?
提问by Sandra Schlichting
I would like to compile NRPEstatic, so I can copy the compiled binary to an OmniOS server, where I don't want gcc to be installed on. I would prefer to install NRPE with SSl support from a repository, but such doesn't seam to exist, so I would like to compile it myself. However the ./configure
script doesn't contain a static option it seams
我想编译NRPE静态,所以我可以将编译后的二进制文件复制到 OmniOS 服务器,我不想在其中安装 gcc。我更喜欢从存储库安装带有 SSl 支持的 NRPE,但是这样并不存在,所以我想自己编译它。但是,该./configure
脚本不包含它接缝的静态选项
~/nrpe-2.15# ./configure --help | grep static
~/nrpe-2.15# ./configure --help | grep share
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
Question
题
How do I compile a program that uses configure
statically?
如何编译configure
静态使用的程序?
采纳答案by ams
Try this:
尝试这个:
./configure LDFLAGS="-static"
回答by srd
For people coming from google, I found that if you have libtool
part of your build, you will need to:
对于来自谷歌的人,我发现如果你有libtool
你的构建的一部分,你需要:
./configure CFLAGS="-static" ....
make LDFLAGS="-all-static"
./configure CFLAGS="-static" ....
make LDFLAGS="-all-static"
You can see that -all-static
with libtool --help --mode=link
你可以看到,-all-static
与libtool --help --mode=link