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 ?

2
  • The -L option to ld adds a directory to the library search list. Commented Apr 11, 2013 at 11:15
  • Hmm... wouldn't using some other glibc than the system one result in problems once the executable links some other library (which in turn was linked against the system libc)? Commented Apr 11, 2013 at 11:22

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.