简体   繁体   English

如何编译 glibc(32 位和 64 位)?

[英]How to you compile glibc (32-bit and 64-bit)?

Right now, I have a modified version of a open-source dependency library (mylib.a file) in my project and thus I have it statically linked via gcc command(s).现在,我的项目中有一个开源依赖库(mylib.a 文件)的修改版本,因此我通过 gcc 命令静态链接了它。 I am getting the error that...我收到的错误是...

"statically linked applications require at runtime the shared libraries from the glibc version used for linking"

My translation: my static dependency library cannot dynamically use glibc;我的翻译:我的静态依赖库不能动态使用glibc; it must also be compiled and dynamically linked.它也必须被编译和动态链接。 Thus, I'm trying to compile and statically link glibc.因此,我正在尝试编译和静态链接 glibc。

I've gather that they would need to be compiled, the *.a library placed in a folder within the project, the "-I//location//" added in for the include headers, and the "-L//location//" added in for the libraries themselves.我收集到它们需要编译,*.a 库放置在项目内的文件夹中,为包含头添加了“-I//location//”,以及“-L//location” //" 为库本身添加。

But, for the question itself...但是,对于问题本身......

How to you compile glibc (32-bit and 64-bit)?如何编译 glibc(32 位和 64 位)?

Through open-source research, I've found this link and I have cloned the repo but I cannot find any documentation on how to actually compile it.通过开源研究,我找到了这个链接,我克隆了这个 repo,但我找不到任何关于如何实际编译它的文档。

git clone git://sourceware.org/git/glibc.git

Any thoughts or suggestions are welcomed.欢迎任何想法或建议。

My translation: my static dependency library cannot dynamically use glibc;我的翻译:我的静态依赖库不能动态使用glibc; it must also be compiled and dynamically linked.它也必须被编译和动态链接。 Thus, I'm trying to compile and statically link glibc.因此,我正在尝试编译和静态链接 glibc。

As nm pointed out, your translation is wrong.正如 nm 指出的那样,您的翻译是错误的。

You are trying to link a fully static executable, and GLIBC is warning you that such executable will not run correctly on any machine with a different version of GLIBC installed.您正在尝试链接一个完全静态的可执行文件,而 GLIBC 警告您此类可执行文件将无法在安装了不同版本 GLIBC 的任何机器上正确运行。

Instead of trying to build a fully-static executable, build it such that it uses libc.so.6 (you can still link mylib.a into such executable).不要尝试构建完全静态的可执行文件,而是构建它以使用libc.so.6 (您仍然可以将mylib.a链接到此类可执行文件)。

IF the reason you added -static to your link is that you have both libmylib.a and libmylib.so , and would like to link in the former instead of the latter, read this answer .如果您在链接中添加-static的原因是您同时拥有libmylib.alibmylib.so ,并且希望链接前者而不是后者,请阅读此答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gcc:在32位平台上编译64位二进制文​​件 - gcc: Compile a 64-bit binary on 32-bit platform 您可以在64位计算机上编译32位Apache DSO(Oracle HTTP服务器)吗? - Can you compile 32-bit Apache DSOs (Oracle HTTP Server) on a 64-bit machine? 如何使用gcc / cmake在64位Linux机器上编译32位二进制文​​件 - How to compile a 32-bit binary on a 64-bit linux machine with gcc/cmake 如何在 64 位 Linux 系统上为 ARM 32 位可执行文件编译 C 代码 - How to compile C-code on a 64-bit Linux system for an ARM 32-bit executable 如何编译与 32 位库链接的 64 位文件 - How to compile 64-bit file linking with 32-bit library 如何在64位CentOS 6上编译和运行32位Python? - How do I compile and run 32-bit Python on 64-bit CentOS 6? 如何在64位Linux机器上编译32位二进制文​​件而不触及CFLAGS环境变量 - How to compile a 32-bit binary on a 64-bit linux machines without touching the CFLAGS environment variable 如何在64位计算机上将libxml2和libcurl编译为32位? - How to compile libxml2 and libcurl to 32-bit under 64-bit machine? 如何检查Linux的32位/ 64位内核 - How to check for 32-bit / 64-bit kernel for Linux 如何测试共享的 object 是 32 位还是 64 位? - How to test if a shared object is 32-bit or 64-bit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM