簡體   English   中英

使用 arm-none-eabi-gcc 編譯並鏈接庫 liba.a 錯誤

[英]Compiling using arm-none-eabi-gcc and linking library liba.a error

我正在 64 位 Linux 機器上用 C 編譯一個 hello world 程序。 我正在使用 GCC ARM 嵌入式工具鏈在帶有 ATMEL AT91SAM9G20 處理器的 FOX G20 V 板上交叉編譯我的程序。

在第一次嘗試時,我在編譯時遇到了一些錯誤,因為程序無法識別 printf、return 等函數(標准 C 函數)。 所以我決定通過執行arm-none-eabi-gcc -o hello hello.c libc.a來建立函數之間的鏈接,我相信這些函數是在 libc.a 庫中定義的(如果我錯了,請糾正我)但結果仍然會導致錯誤:

libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x16): undefined reference to `_exit'
libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
collect2: error: ld returned 1 exit status

我真的不確定為什么即使我已經將庫鏈接到應用程序,程序仍然無法識別標准函數。 如果有人有理由解釋為什么,或者我如何解決這個問題的解決方案,我將不勝感激。

更新

我已經從這里下載了 glibc 庫。 我已經從在newlib-2.1.0/libgloss/arm找到的syscalls.c庫編譯並創建了一個靜態庫,當我將該庫鏈接到我的應用程序代碼時,我仍然遇到相同的錯誤。

嘗試執行這個:

arm-none-eabi-gcc --specs=rdimon.specs -lgcc -lc -lm -lrdimon -o hello hello.c

您的工具包似乎提供了 librdimon.a,這是一個提供基本標准 C 函數的庫。

我收到此錯誤是因為我的二進制文件不適合 ROM。

我的第一個錯誤是:

address 0x34000 of arm_flash.elf section `.mmu_tbl' is not within region `ps7_ram_0`

然后我得到了相同的未定義參考錯誤列表。

我需要通過從我的 C++ 代碼中刪除new關鍵字和所有動態內存分配來減少二進制大小。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM