This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Build a program using a custom glibc


On 26 May 2012 08:58, Amittai Aviram <amittai.aviram@yale.edu> wrote:
> I have managed to build glibc 2.14 and install it in directory ~/glibc/glibc_install. ?So now I want to build and run programs using this C library instead of my system's default C library. ?First, to be sure that I was using my custom glibc, I added a call to puts into glibc/stdio-common/printf.c:__printf to print a message. ?Then I rebuilt and reinstalled glibc. ?Then I wrote a "Hello, World" program and built (compiled and linked) it as follows:
>
> gcc -nodefaultlibs -static -libgcc -L~/GLIBC/glibc_install/lib -o myprog myprog.c
>
> But I get the following linker error report:
>
> /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
> (.text+0x19): undefined reference to `__libc_csu_init'
> /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
> (.text+0x25): undefined reference to `__libc_start_main'
> /tmp/ccACTQEp.o: In function `main':
> c1.c:(.text+0xa): undefined reference to `puts'
> collect2: ld returned 1 exit status
>
> What am I doing wrong? ?Thanks!

You can do the compile and link separately. And for the linker, you
provide the crt*.o files from ~/GLIBC/glibc_install/lib.

Try running the gcc command with a -v and you'll see what the linker
gets called with. You can then use the same command with your paths
adjusted to use your glibc.

Once you get this working, it would be great if you could add this to
the glibc wiki in the tips and tricks section:

http://sourceware.org/glibc/wiki


-- 
Siddhesh Poyarekar
http://siddhesh.in


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]