We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,I am trying to compile a very simple code that uses the function "aligned_alloc", using ARM Toolchain "gcc-arm-none-eabi-7" but every time I am receiving the error bellow
user@laptop:~/Downloads$ arm-none-eabi-gcc mem_align.c /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-aligned_alloc.o): In function `aligned_alloc': aligned_alloc.c:(.text+0x14): undefined reference to `posix_memalign' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-exit.o): In function `exit': exit.c:(.text+0x2c): undefined reference to `_exit' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r': sbrkr.c:(.text+0x18): undefined reference to `_sbrk' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-writer.o): In function `_write_r': writer.c:(.text+0x24): undefined reference to `_write' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-closer.o): In function `_close_r': closer.c:(.text+0x18): undefined reference to `_close' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r': fstatr.c:(.text+0x20): undefined reference to `_fstat' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r': isattyr.c:(.text+0x18): undefined reference to `_isatty' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r': lseekr.c:(.text+0x24): undefined reference to `_lseek' /opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-none-eabi/bin/../arm-none-eabi/libc/usr/lib/libc.a(lib_a-readr.o): In function `_read_r': readr.c:(.text+0x24): undefined reference to `_read' collect2: error: ld returned 1 exit status
the code I am trying to compile is
#include <stdio.h> #include <stdlib.h> int main(void) { char *str = aligned_alloc(32, 256); printf("Data aligned: %p",(void*) str); return 0; }
Do you have any suggestion on how to fix the problem?Thank you,Thanos
That means you are missing an implementation for these functions. If you pass '--specs=rdimon.specs' in your linking command-line the toolchain will include our default implementations for these, assuming you are running on a semihosted system.
Sorry for the late answer, thank you very much for your answer, I will check it