在 Ubuntu 11.04 上构建静态版本的 Python

发布于 2024-12-07 02:47:49 字数 1156 浏览 1 评论 0原文

在查看类似问题后,看来我应该能够构建因此,Python 的静态版本:

./configure --disable-shared LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"

但是,运行按上面配置的 make 最终会出现一些警告和错误:

gcc -pthread -static -static-libgcc -Xlinker -export-dynamic -o python \
            Modules/python.o \
            libpython2.7.a -lpthread -ldl  -lutil   -lm  
<SNIP>
libpython2.7.a(posixmodule.o): In function `posix_initgroups':
Python-2.7.2/./Modules/posixmodule.c:3981: warning: Using 'initgroups' in
statically linked applications requires at runtime the shared
libraries from the glibc version used for linking

/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in
`/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../libc.a(strcmp.o)'
can not be used when making an executable;
recompile with -fPIE and relink with -pie

collect2: ld returned 1 exit status

我被卡住了。它似乎要求我重新编译 libc。我认为 -static-libgcc 就足够了,但显然还不够。有谁知道这里发生了什么,以及如何实现我在 Ubuntu 11.04 上构建静态 python 的目标?

After looking at a similar question, it appears that I am supposed to be able to build a static version of Python thusly:

./configure --disable-shared LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"

However, running make configured as above eventually barfs up some warnings and an error:

gcc -pthread -static -static-libgcc -Xlinker -export-dynamic -o python \
            Modules/python.o \
            libpython2.7.a -lpthread -ldl  -lutil   -lm  
<SNIP>
libpython2.7.a(posixmodule.o): In function `posix_initgroups':
Python-2.7.2/./Modules/posixmodule.c:3981: warning: Using 'initgroups' in
statically linked applications requires at runtime the shared
libraries from the glibc version used for linking

/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in
`/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../libc.a(strcmp.o)'
can not be used when making an executable;
recompile with -fPIE and relink with -pie

collect2: ld returned 1 exit status

I'm stuck. It appears to be asking me to recompile libc. I thought -static-libgcc would be enough, but apparently it is not. Does anyone know what is going on here, and how to achieve my goal of building a static python on Ubuntu 11.04?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文