Reputation: 60451
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
?
Upvotes: 1
Views: 898
Reputation: 14781
Use -L pathname
to explicitly specify a pathname to ld
as Barmar has said in the comment.
It's suggested to use static linking -static
or there might be problems during execution I think.
Actually my own solution to this problem would be: compile and link the source code as normal, and invoke with LD_PRELOAD
set to your specified version of shared objects.
See http://linux.die.net/man/8/ld.so
Upvotes: 1