This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
How to use native newlib on x86_64-linux-gnu or i386-linux-gnu?
- From: Zygmunt Krynicki <z dot krynicki at samsung dot com>
- To: newlib at sources dot redhat dot com
- Date: Fri, 26 Jun 2009 13:00:52 +0200
- Subject: How to use native newlib on x86_64-linux-gnu or i386-linux-gnu?
- Reply-to: z dot krynicki at samsung dot com
Hello.
I'm trying to use native build of newlib (currently on x86_64-linux-gnu)
to build simple programs. My goal is to allow application developers to
use native newlib as a target for developing applications that could be
later ported (rebuilt) for some embedded target.
I noticed that there is an Ubuntu package for newlib (called
libnewlib-dev and libnewlib0) so my guess was that it's the least-effort
method of building simple application that could link with newlib
instead of glibc.
I attempted to build this simple hello-world program:
zyga@XXX:~/newlib-sample-prog$ cat test.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char *argv[]) {
printf("Hello newlib!\n");
return EXIT_SUCCESS;
}
I understand that I don't need a cross compiler in this case so I tried
building with various combination of -nostdlib -nostdinc -nostartfiles
-nodefaultlibs to prevent gcc from using glibc but then I get undefined
references (I'm trying to do a static build) to various functions like
sbrk(), write(), close() etc. All those references come from
/usr/lib/newlib/x86_64-linux-gnu/lib/libc.a which leads me to believe
that native newlib simply depends on some other libc and is not using
linux syscalls to implement everything directly. Doing a simple nm
--defined | grep write; seems to confirm that. I apparently do something
wrong.
I tried googling, read couple of years of newlib's mailing list archive
but apparently nobody has this issue which leads me to believe that
either nobody is doing it or I made some incredibly basic mistake. Could
someone please tell me what should I do to be able to build, link and
run native programs on either x86_64-linux-gnu or i386-linux-gnu that
depend on newlib instead of glibc?
Best regards
Zygmunt Krynicki