简体   繁体   English

交叉编译错误“ arm-none-eabi-g ++找不到条目符号”

[英]Cross compile error “arm-none-eabi-g++ cannot find entry symbol”

I have a problem about cross compile. 我有关于交叉编译的问题。

#include <stdio.h>

int main()
{
    printf("hello\n");
    return 0;
}

this is a simple hello world code I used. 这是我使用的一个简单的hello world代码。

I'm using arm-none-eabi-g++, downloaded from mentor graphics. 我正在使用从导师图形下载的arm-none-eabi-g ++。 Here is the error. 这是错误。 I don't know what lib is missed. 我不知道会错过什么lib。

/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 00008018
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-abort.o): In function `abort':
abort.c:(.text+0x10): undefined reference to `_exit'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text+0x1c): undefined reference to `_kill'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text+0x44): undefined reference to `_getpid'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text+0x18): undefined reference to `_sbrk'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text+0x20): undefined reference to `_write'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text+0x18): undefined reference to `_close'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text+0x1c): undefined reference to `_fstat'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text+0x18): undefined reference to `_isatty'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text+0x20): undefined reference to `_lseek'
/home/kang/Utils/arm-2013.05/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text+0x20): undefined reference to `_read'
collect2: error: ld returned 1 exit status

and this is compiler version. 这是编译器版本。

$ arm-linux-gnueabi-g++ -v $ arm-linux-gnueabi-g ++ -v

Using built-in specs. 使用内置规格。 COLLECT_GCC=/home/kang/Utils/arm-2013.05/bin/arm-none-eabi-g++ COLLECT_LTO_WRAPPER=/home/kang/Utils/arm-2013.05/bin/../libexec/gcc/arm-none-eabi/4.7.3/lto-wrapper Target: arm-none-eabi Configured with: /scratch/jbrown/2013.05-arm-eabi-release/src/gcc-4.7-2013.05/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2013 -D__CS_SOURCERYGXX_MIN__=5 -D__CS_SOURCERYGXX_REV__=23 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-shared --enable-lto --with-newlib --with-pkgversion='Sourcery CodeBench Lite 2013.05-23' --with-bugurl= https://sourcery.mentor.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --wit COLLECT_GCC = / home / kang / Utils / arm-2013.05 / bin / arm-none-eabi-g ++ COLLECT_LTO_WRAPPER = / home / kang / Utils / arm-2013.05 / bin /../ libexec / gcc / arm-none-eabi / 4.7.3 / lto-wrapper目标:arm-none-eabi配置为:/scratch/jbrown/2013.05-arm-eabi-release/src/gcc-4.7-2013.05/configure --build = i686-pc-linux-gnu --host = i686-pc-linux-gnu --target = arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite- multilibs --with-gnu-as --with-gnu-ld --with-specs ='%{保存温度:-fverbose-asm} -D__CS_SOURCERYGXX_MAJ __ = 2013 -D__CS_SOURCERYGXX_MIN __ = 5 -D__CS_SOURCERYGXX_REV __ = 23%{O2:% {!fno-remove-local-statics:-fremove-local-statics}}%{O *:%{O | O0 | O1 | O2 | Os:;:%{!fno-remove-local-statics:-fremove -local-statics}}}'---enable-languages = c,c ++ --disable-shared --enable-lto --with-newlib --with-pkgversion ='Sourcery CodeBench Lite 2013.05-23'--with- bugurl = https://sourcery.mentor.com/GNUToolchain/ --disable-nls --prefix = / opt / codesourcery --with-headers =是--wit h-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/jbrown/2013.05-arm-eabi-release/install/arm-none-eabi --with-gmp=/scratch/jbrown/2013.05-arm-eabi-release/obj/pkg-2013.05-23-arm-none-eabi/arm-2013.05-23-arm-none-eabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpfr=/scratch/jbrown/2013.05-arm-eabi-release/obj/pkg-2013.05-23-arm-none-eabi/arm-2013.05-23-arm-none-eabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpc=/scratch/jbrown/2013.05-arm-eabi-release/obj/pkg-2013.05-23-arm-none-eabi/arm-2013.05-23-arm-none-eabi.extras/host-libs-i686-pc-linux-gnu/usr --with-ppl=/scratch/jbrown/2013.05-arm-eabi-release/obj/pkg-2013.05-23-arm-none-eabi/arm-2013.05-23-arm-none-eabi.extras/host-libs-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/jbrown/2013.05-arm-eabi-release/obj/pkg-2013.05-23-arm-none-eabi/arm-2013.05-23-arm-none-eabi.extras/host-libs-i686-pc-linux-gnu/usr --with-libelf=/scratch/jbrown/2 h-sysroot = / opt / codesourcery / arm-none-eabi --with-build-sysroot = / scratch / jbrown / 2013.05-arm-eabi-release / install / arm-none-eabi --with-gmp = / scratch /jbrown/2013.05-arm-eabi-release/obj/pkg-2013.05-23-arm-none-eabi/arm-2013.05-23-arm-none-eabi.extras/host-libs-i686-pc-linux-gnu / usr --with-mpfr = / scratch / jbrown / 2013.05-arm-eabi-release / obj / pkg-2013.05-23-arm-none-eabi / arm-2013.05-23-arm-none-eabi.extras / host -libs-i686-pc-linux-gnu / usr --with-mpc = / scratch / jbrown / 2013.05-arm-eabi-release / obj / pkg-2013.05-23-arm-none-eabi / arm-2013.05-23 -arm-none-eabi.extras / host-libs-i686-pc-linux-gnu / usr --with-ppl = / scratch / jbrown / 2013.05-arm-eabi-release / obj / pkg-2013.05-23-arm -none-eabi / arm-2013.05-23-arm-none-eabi.extras / host-libs-i686-pc-linux-gnu / usr --with-host-libstdcxx ='-static-libgcc -Wl,-Bstatic ,-lstdc ++,-Bdynamic -lm'--with-cloog = / scratch / jbrown / 2013.05-arm-eabi-release / obj / pkg-2013.05-23-arm-none-eabi / arm-2013.05-23-arm- none-eabi.extras / host-libs-i686-pc-linux-gnu / usr --with-libelf = / scratch / jbrown / 2 013.05-arm-eabi-release/obj/pkg-2013.05-23-arm-none-eabi/arm-2013.05-23-arm-none-eabi.extras/host-libs-i686-pc-linux-gnu/usr --disable-libgomp --disable-libitm --enable-poison-system-directories --with-build-time-tools=/scratch/jbrown/2013.05-arm-eabi-release/install/arm-none-eabi/bin --with-build-time-tools=/scratch/jbrown/2013.05-arm-eabi-release/install/arm-none-eabi/bin Thread model: single gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-23) 013.05-arm-eabi-release / obj / pkg-2013.05-23-arm-none-eabi / arm-2013.05-23-arm-none-eabi.extras / host-libs-i686-pc-linux-gnu / usr- -disable-libgomp --disable-libitm --enable-poison-system-directories --with-build-time-tools = / scratch / jbrown / 2013.05-arm-eabi-release / install / arm / none-eabi / bin --with-build-time-tools = / scratch / jbrown / 2013.05-arm-eabi-release / install / arm-none-eabi / bin线程模型:单个gcc版本4.7.3(Sourcery CodeBench Lite 2013.05-23)

You downloaded the wrong toolchain. 您下载了错误的工具链。

arm-linux-gnueabi-g++ is built using arm-none-eabi , which is used for bare metal programs. arm-linux-gnueabi-g++是使用arm-none-eabi ,用于裸机程序。 This does not contain libc ie the standard libraries (glibc or eglibc) are not present in this toolchain. 它不包含libc,即该工具链中不存在标准库(glibc或eglibc)。

So, you need to download the arm-none-linux-gnueabi toolchain (ie arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 , not arm-2013.11-24-arm-none-eabi-i686-pc-linux-gnu.tar.bz2 ). 因此,您需要下载arm-none-linux-gnueabi工具链(即arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 ,而不是arm-2013.11-24-arm-none-eabi-i686-pc-linux-gnu.tar.bz2 )。

To verify the above, type: 要验证以上内容,请输入:

cd /home/kang/Utils/arm-2013.05/arm-none-eabi 

Here you will find only bin include lib share , and no libc directory. 在这里,您只会找到bin include lib share ,没有libc目录。

Download arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 ; 下载arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 ; here you'll find a folder arm-2013.05/arm-none-linux-gnueabi/libc . 在这里您会找到一个文件夹arm-2013.05/arm-none-linux-gnueabi/libc

You can also verify by writing: 您还可以通过以下方式进行验证:

arm-linux-eabi-g++ -print-sysroot and 
arm-none-linux-gnueabi-g++ -print-sysroot

Also refer to this previous question: how to work with external libraries when cross compiling? 还请参考前面的问题: 交叉编译时如何使用外部库?

I'm using arm-linux-gnueabi-g++. 我正在使用arm-linux-gnueabi-g ++。 it downloaded form mentor graphics. 它下载了表单指导者图形。

This is misnamed. 这是错误的名称。 All your output suggests that Mentor Graphics have packaged a arm-none-gnueabi toolchain and incorrectly named it arm-linux-gnueabi (which doesn't even fit naming conventions). 您的所有输出都表明Mentor Graphics已打包了 arm-none-gnueabi工具链,并错误地将其命名为 arm-linux-gnueabi (甚至不符合命名约定)。

sorry, I mistyped my compiler. 抱歉,我输入了错误的编译器。 I'm using arm-none-eabi-g++ 我正在使用arm-none-eabi-g ++

Get yourself a version of the arm-none-linux-gnueabi toolchain (ie targetting GNU/Linux rather than EABI). 为自己获取arm-none-linux-gnueabi工具链的版本(即,针对GNU / Linux而不是EABI)。

This one will contain the GCC runtime which interfaces with the Linux operating system. 这将包含与Linux操作系统连接的GCC运行时。 All those functions you're missing right now are part of that interface. 您现在所缺少的所有这些功能都是该界面的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM