我想在Linux 64位機器上用C編譯hello世界程序。我正在使用ARM交叉編譯器將我的應用程序加載到ARM處理器上。但是,使用arm-none-eabi-gcc -o hello hello.c
編譯代碼時,我得到了一系列的錯誤:使用arm-none-eabi-gcc編譯hello world程序時出錯編號
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function
exit': exit.c:(.text.exit+0x2c): undefined reference to
_exit' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function_sbrk_r': sbrkr.c:(.text._sbrk_r+0x18): undefined reference to
_sbrk' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function_write_r': writer.c:(.text._write_r+0x20): undefined reference to
_write' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function_close_r': closer.c:(.text._close_r+0x18): undefined reference to
_close' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function_fstat_r': fstatr.c:(.text._fstat_r+0x1c): undefined reference to
_fstat' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function_isatty_r': isattyr.c:(.text._isatty_r+0x18): undefined reference to
_isatty' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function_lseek_r': lseekr.c:(.text._lseek_r+0x20): undefined reference to
_lseek' /home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function_read_r': readr.c:(.text._read_r+0x20): undefined reference to
_read' collect2: error: ld returned 1 exit status
當我嘗試做編譯:arm-none-eabi-gcc -c hello.c
,它創建了一個目標代碼hello.o
告訴我,編譯器運行正常。
有人可能會告訴我爲什麼我的彙編是返回這樣的錯誤嗎?
UPDATE
我現在認識到C運行時庫不包含在彙編。有誰知道我需要包含在編譯中的任何選項,或者如何鏈接庫以便能夠使用標準函數(例如printf)?
外觀http://embdev.net/topic/129753 –
這可能會幫助你http://stackoverflow.com/questions/13235748/linker-error-on-ac-project-using-eclipse –
它缺乏你libc低級函數。它依賴於平臺,所以arm-none-eabi-gcc工具鏈不會擁有它。它通常由芯片製造商提供。目標平臺是什麼? **如果你停止使用libc函數(printf,malloc,open等),你可以編譯你的程序。 –