Linux 我如何从源代码静态构建 GDB?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9364685/
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 i can static build GDB from source?
提问by G-71
I've download gdb-6.5.bz2.tar. Untar this file. I write: LDFLAGS=-static ./configure
我已经下载了 gdb-6.5.bz2.tar。解压这个文件。我写: LDFLAGS=-static ./configure
but as a result i get a gdb, which require a so files, for instance: ncurses.so.5 libc.so.0 etc
但结果我得到了一个 gdb,它需要一个 so 文件,例如:ncurses.so.5 libc.so.0 等
How i can build statically ?
我如何静态构建?
采纳答案by unwind
This messageseems to imply that the correct usage is
此消息似乎暗示正确的用法是
$ make LDFLAGS=-static
Which seems surprising. Unfortunately, it also says it fails to build, and there are no follow-ups. Still the message is from 1999 so everything might have changed, perhaps the proper way today is to do it your way.
这似乎令人惊讶。不幸的是,它还说它无法构建,并且没有后续。仍然是 1999 年的信息,所以一切都可能发生了变化,也许今天的正确方法是按照自己的方式去做。
回答by Vijay Nag
You can use the following options for configurescript to generate a static GDB executable:
您可以使用以下配置脚本选项来生成静态 GDB 可执行文件:
./configure --prefix=<> --enable-static=yes && make && make install
回答by Michael Goldshteyn
Both gcc and gdb disrespect the --enable-static
flag which should be passed to configure
, the correct way to do this is:
gcc 和 gdb--enable-static
都不尊重应该传递给的标志configure
,正确的方法是:
In the case of gdb 8.0, you have to also add the --disable-interprocess-agent
to successfully build a static version:
在 gdb 8.0 的情况下,您还必须添加--disable-interprocess-agent
才能成功构建静态版本:
mkdir build-gdb && cd build-gdb && ../configure --prefix=... --enable-static --disable-interprocess-agent ...
mkdir build-gdb && cd build-gdb && ../configure --prefix=... --enable-static --disable-interprocess-agent ...
In the case of gcc 7.1, you have to also add the --disable-libcc1
to successfully build a static version:
在 gcc 7.1 的情况下,您还必须添加--disable-libcc1
才能成功构建静态版本:
mkdir build-gcc && cd guild-gcc && ../configure --prefix=... --enable-static --disable-shared --disable-libcc1 ...
mkdir build-gcc && cd guild-gcc && ../configure --prefix=... --enable-static --disable-shared --disable-libcc1 ...