This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

undefined reference in newlib porting


hi, your guys:
    I have port the newlib to my RISC, and it was built successfully.
But when I build a helloworld.c function:

   int main()
  {
       printf("Hello World!!!\n");
       return 0;
 }

with the command: rice-elf-gcc  helloworld.c.
There are errors like this:

/usr/local/cross/rice-elf/lib/gcc/rice-elf/4.3.0/../../../../rice-elf/lib/libc.a(lib_a-makebuf.o):
In function `_year':
(.text.__smakebuf_r+0x114): undefined reference to `isatty'
/usr/local/cross/rice-elf/lib/gcc/rice-elf/4.3.0/../../../../rice-elf/lib/libc.a(lib_a-writer.o):
In function `/usr/local/cross/rice-elf/lib/gcc/rice-elf/4.3.0/include':
(.text._write_r+0x38): undefined reference to `write'
/usr/local/cross/rice-elf/lib/gcc/rice-elf/4.3.0/../../../../rice-elf/lib/libc.a(lib_a-closer.o):
In function `y':
(.text._close_r+0x28): undefined reference to `close'
/usr/local/cross/rice-elf/lib/gcc/rice-elf/4.3.0/../../../../rice-elf/lib/libc.a(lib_a-fstatr.o):
In function `_fstat_r':
fstatr.c:(.text._fstat_r+0x30): undefined reference to `fstat'
/usr/local/cross/rice-elf/lib/gcc/rice-elf/4.3.0/../../../../rice-elf/lib/libc.a(lib_a-lseekr.o):
In function `ze':
(.text._lseek_r+0x38): undefined reference to `lseek'
/usr/local/cross/rice-elf/lib/gcc/rice-elf/4.3.0/../../../../rice-elf/lib/libc.a(lib_a-readr.o):
In function `_read_r':
readr.c:(.text._read_r+0x38): undefined reference to `read'

I have to say I have already defined the functions in liblgoss like
the following:

#include <sys/stat.h>
#include "../syscall.h"

int
_read (file, ptr, len)
     int    file;
     char * ptr;
     int    len;
{
  return 0;
}

int
_lseek (file, ptr, dir)
     int file;
     int ptr;
     int dir;
{
  return 0;
}

int
_write (file, ptr, len)
     int    file;
     char * ptr;
     int    len;
{
  return 0;
}

int
_open (path, flags)
     const char * path;
     int flags;
{
  return 0;
}

int
_close (file)
     int file;
{
  return 0;
}

void
_exit (n)
     int n;
{
  return 0;
}


caddr_t
_sbrk (incr)
     int incr;
{
  return (caddr_t) 0;
}

int
_fstat (file, st)
     int file;
     struct stat * st;
{
  st->st_mode = S_IFCHR;
  return 0;
}

int
_unlink ()
{
  return -1;
}

int
isatty (fd)
     int fd;
{
  return 0;
}

int
_raise ()
{
  return 0;
}

int
_times ()
{
  return 0;
}

int
_kill (pid, sig)
     int pid;
     int sig;
{
  return 0;
}

int
_getpid (void)
{
  return 0;
}

This is just for test. So I leave the function as empty.
I don't know whether the underscore symbol would cause the problem.
But I wonder whether there are system default functions(for those
functions in libgloss, I noticed the files in newlib/libgloss/, but I
am not sure.).

Can anybody give me some advice, thanks very much.


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