Linker error

Phung Nguyen
Wed Aug 25 09:01:00 GMT 2010

Thank you for your reply.

I downloaded, put it into libgloss/config and rebuild newlib
but it doesn't work. Still got the same error message when making and
there is no library created in libgloss/xc16x.

I am looking forward to any other idea.

Best regards,

> On Mon, Aug 23, 2010 at 10:55 PM, Jeff Johnston <> wrote:
>> On 22/08/10 09:55 AM, Phung Nguyen wrote:
>>> Dear all,
>>> I am trying to build cross compiler for xc16x. I built successfully
>>> binutils 2.18; gcc 4.0 and newlib 1.18. Everything is fine when
>>> compiling a simple C file without any library call. It is also fine
>>> when making a simple call to printf like printf("Hello world").
>>> However, i got error message from linker when call printf("i=%i",i);
>>> The error message is as follows
>>> /home/guest/xc16x/lib/gcc/xc16x-elf/lib/xc16xl/libc.a(lib_a-sbrkr.o):
>>> In function _sbrk_r:
>>> /home/guest/newlib-1.18.0/newlib/libc/reent/sbrkr.c:60: undefined
>>> reference to __sbrk
>>> /home/guest/fromKpit/newlib-1.18.0/newlib/libc/reent/sbrkr.c:60:
>>> undefined reference to __sbrk
>>> ....
>>> collect2: ld returned 1 exit status
>>> make: *** [bubble.out] Error 1
>>> In directory libgloss/xc16x, there are neccessary files like sbrk.c;
>>> read.c; write.c...
>>> I logged the make and found out an error when making libgloss as in
>>> the attached file. Is it the reason to cause the problem?
>> Yes.  This should not occur.  I just noticed that I checked in a file in the
>> wrong location for xc16x...there should be an file in
>> libgloss/config, but it got put into the libgloss/xc16x directory.  Try
>> updating from the current repository and rebuilding newlib/libgloss again.
>>> when making libgloss, in directory libgloss/libnosys, there are all .o
>>> files and but int libgloss/xc16x, there are no files
>>> except Makefile, config.log and config.status. Is it enough?
>> No, you should have built a library there as mentioned above.
>>> Is there any idea how to solve the problem? I highly appreciate any help.
>>> Best regards,
>>> Phung
>> -- Jeff J.

More information about the Newlib mailing list