Page 1 of 1

installing newlib?

Posted: Mon Dec 24, 2007 10:52 pm
by hazardoxide
ok. I have cygwin with gcc, and binutils. i downloaded newlib. how do i add it to use it with gcc?

Posted: Wed Dec 26, 2007 6:28 am
by JamesM
There are several methods.

1) Add your glue code to the libgloss directory and make newlib (A la the wiki article)

2) What I do. Compile newlib with target architecture i586-elf. It will compile but won't contain any glue code so won't work as yet. I then compile my userland libraries, make a new directory (tmp) and:

* copy the newlib .a file into /tmp.
* extract the newlib .a file (remember it's just a tar archive).
* copy all the .o files generated from my userland compilation into /tmp
* cd /tmp && tar -cf libc.a *.o && ranlib libc.a
* copy tmp/libc.a to wherever my gcc/lib symbolic link for libc.a points to.
* hey presto! rm -Rf /tmp and you're all done!

The slight advantage to this method is (a) Its quicker to build because I don't have to rebuild newlib every time (make NEVER seems to get depedencies fully correct) and (b) I don't have to have the entire newlib source tree in subversion, which is slow enough as it is.

Cheers,

JamesM

PS: This may look like a dirty hack, but look at the newlib makefiles - this is how they do it!