1

I want to do some modifications to the glibc library. The first step is to be able to use a specific version when I compile a program. I'm under ubuntu 12.10 and my directories are :

/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)

The helloworld.c is the following:

#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;
}

First how can I print the version of glibc ? (I think that there is a macro/constant in glibc for that).

Second, what command line should I use to compile my helloworld.c file to use the glibc that is in /mydirectory/glibc-2.17-build ?

4

1 回答 1

1

正如 Barmar 在评论中所说,用于-L pathname显式指定路径名。 建议使用静态链接,否则我认为在执行过程中可能会出现问题。ld
-static

实际上,我自己对这个问题的解决方案是:正常编译和链接源代码,并使用LD_PRELOADset 调用您指定的共享对象版本。
http://linux.die.net/man/8/ld.so

于 2013-04-11T11:31:12.297 回答