linking with libraries not working..
Posted: Tue Jun 02, 2009 10:54 am
Hi, I'm trying to get some basic userland stuff going, and one step is of course libc(I already got a common linker script and crt0 and such, so I can run a basic C app without a library)
So, I decided I was going to go a different route and synthesize my own libc out of BSD libcs out there(most notably OpenBSDs)
Well, I got all the string stuff copied in and made a nice generic makefile for it and got it to all compile. Then I put it into a library with
with OBJS being a list of objs and OUTFILE being libc.a
so libc.a goes into my lib directory and I make a simple C program that includes string.h and references strlen
the relevant part of my linker script is
and then I use on the ld command line for the application
and when linking it gives undefined symbol strlen. Well, but when I attach ../libc/strlen.o to OBJS it will link fine..
anyone see what I'm doing wrong here with lcreating and linking with this library?
edit:
oh wait, I didn't compile the sources with the cross compiler, only tried linking them.
but now I have a problem with my cross compiler. It didn't generate _types.h and cdefs.h files, and I tried copying them from my main compiler's include, but it doesn't work cause the cross compiler doesn't recognize __int32 and such things used internally
So, I decided I was going to go a different route and synthesize my own libc out of BSD libcs out there(most notably OpenBSDs)
Well, I got all the string stuff copied in and made a nice generic makefile for it and got it to all compile. Then I put it into a library with
Code: Select all
/usr/cross/i586-elf/bin/ar crs ${OUTFILE} ${OBJS}
so libc.a goes into my lib directory and I make a simple C program that includes string.h and references strlen
the relevant part of my linker script is
Code: Select all
ENTRY (__main)
OUTPUT_FORMAT(binary)
STARTUP(../../lib/crt0.o)
SEARCH_DIR(../../lib)
Code: Select all
LDFLAGS = -nostartfiles -nodefaultlibs -nostdlib -lc
...
login.bin: ${OBJS}
ld -T ../../A56.ld ${LDFLAGS} ${OBJS} -o ${OUTFILE}
anyone see what I'm doing wrong here with lcreating and linking with this library?
edit:
oh wait, I didn't compile the sources with the cross compiler, only tried linking them.
but now I have a problem with my cross compiler. It didn't generate _types.h and cdefs.h files, and I tried copying them from my main compiler's include, but it doesn't work cause the cross compiler doesn't recognize __int32 and such things used internally