lnker error when compiling with g++

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys, I'm trying to link a project using g++ instead of gcc however I get this linker error:

Any tips guys?

 

04:54:35 **** Build of configuration Default for project Embedded ****
make TARGET=sama5d4-xplained 
LINK build/sama5d4-xplained/ddram/getting-started_with_blue.elf
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libc_nano.a(lib_a-abort.o): In function `abort':
abort.c:(.text.abort+0xa): undefined reference to `_exit'
collect2.exe: error: ld returned 1 exit status
make: *** [../../scripts/Makefile.rules:117: build/sama5d4-xplained/ddram/getting-started_with_blue.elf] Error 1

 

Last Edited: Sun. Feb 9, 2020 - 05:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay lads, I've cleared most of the errors by setting the linker flags - "--specs=nano.specs -specs=nosys.specs".

I'm left with one error:

 

d:/arm dependencies/gcc-arm/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7-ar/fpv3/hard\libnosys.a(sbrk.o): In function `_sbrk':
sbrk.c:(.text._sbrk+0x8): undefined reference to `end'
sbrk.c:(.text._sbrk+0xc): undefined reference to `end'

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got it, just had to specify "end" in the linker file.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

C++ compiles, links and builds an binary okay.

But when I execute a binary with C++ the development board fails to initialise correctly.

 

Come on guys, one last push and we have the Atmel software package supporting C++.

 

Wm.