我想对glibc
库进行一些修改。第一步是在编译程序时能够使用特定版本。我在ubuntu 12.10下,我的目录是:
/mydirectory/glibc-2.17 (where I have extracted the last version from the website)
/mydirectory/glibc-2.17-build (where I have executed the configure and make command)
/mydirectory/test/helloworld.c (where I have my helloworld program)
helloworld.c
如下:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
char glibc[256] = "xxxx"; /* How to detect the glibc version here ? */
printf("hello, world\n");
printf("glibc version = %s\n", glibc);
return 0;
}
首先,我如何打印glibc
的版本? (我认为glibc中有一个宏/常量)。
其次,我应该使用什么命令行来编译我的helloworld.c
文件以使用glibc
中的/mydirectory/glibc-2.17-build
?
答案 0 :(得分:1)
使用-L pathname
明确指定Barmar在评论中说明的ld
路径名。
建议使用静态链接-static
或者我认为在执行期间可能存在问题。
实际上我自己解决这个问题的方法是:正常编译和链接源代码,并调用LD_PRELOAD
设置为指定版本的共享对象。
见http://linux.die.net/man/8/ld.so