Page 1 of 1
Getting C Library File to Work
Posted: Wed Jan 17, 2007 8:53 am
by AJ
Hi All,
I am creating a libc.a file for my OS and am trying to link it in with a my kernel to test it. I am asking in this forum as this seems more of a general C rather than an OS dev issue.
Every time I try to link it, I get the message:
Code: Select all
libc.a: could not read symbols: Memory Exhausted.
Which seems odd as so far I only have a single function in my libc!
I am building the library with DJGPP, using:
...and creating the archive with:
I attempt to link in my library with:
Code: Select all
ld -T link.ld -o bin\caracal.sys asm\kernel.o bin\*.o lib\*.o lib\*.a
Where the only parameter I have actually added is the 'lib\*.a'.
Does anyone have any ideas where I am going wrong?
Thanks,
Adam
Posted: Wed Jan 17, 2007 9:29 am
by Brynet-Inc
Hmm..
Turn on verbose and add the c option:
Also try this after the above command:
Posted: Wed Jan 17, 2007 10:36 am
by AJ
Thanks for the suggestions. Verbose mode does not seem to give any more information - ar itself completes fine.
I ran ranlib immediately afterwards as suggested but this did not seem to make a difference - I believe the 's' parameter does the same job? (could be wrong as I've not used ar before).
Adam
Posted: Wed Jan 17, 2007 11:11 am
by Candy
AJ wrote:Thanks for the suggestions. Verbose mode does not seem to give any more information - ar itself completes fine.
I ran ranlib immediately afterwards as suggested but this did not seem to make a difference - I believe the 's' parameter does the same job? (could be wrong as I've not used ar before).
That's true. Most people don't use that because they tend to think along the lines of the old commands.
Posted: Thu Jan 18, 2007 12:18 am
by Solar
Hmmm... I use the equivalent of "gcc myprog.c libc.a -o myprog", which works fine. I would suggest first testing your toolchain with some simple "exercise" code outside your OS source tree, i.e. build a lib with one function in it and a main() that uses that function, and see that it links correctly without using your custom link.ld. Then work from there...
Posted: Thu Jan 18, 2007 3:32 am
by AJ
Solar wrote:...build a lib with one function in it and a main() that uses that function, and see that it links correctly without using your custom link.ld. Then work from there...
Thanks - will do. In order to test my (very minimal - single function!) libc I have currently got around it by just linking the .o file in the normal way. Obviously when my libc grows, this is no good. I'll keep working the problem.
While I'm at it, I must remember to download your PDCLib to see how a library
should be done...
Cheers,
Adam
Posted: Thu Jan 18, 2007 3:43 am
by Solar
AJ wrote:While I'm at it, I must remember to download your PDCLib to see how a library should be done...
It's my first, so don't put too much trust into me doing it "right". For example, I don't create the symbol index as of v0.4.1, as I didn't know about that option prior to this thread.
Posted: Mon Feb 12, 2007 3:05 am
by AJ
For anyone in a similar situation, I think I have solved it. My C library contained system calls which were written in separate NASM modules instead of inline assembly.
For various reasons, I had NASM compiling in AOUT. Changing this seemed to make things go much more smoothly!
Cheers,
Adam