G ++ ARM交叉编译:未定义的引用

时间:2016-02-14 18:17:44

标签: c++ gcc arm cross-compiling

我正在尝试用arm-none-eabi-g ++编译Jasmine OpenSSD代码。 但是,它首先因以下错误消息而失败

/usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/bin/ld: cannot find -lstdc++

为了解决这个问题,我确保用libstdc ++链接.a是可能的。一旦我修复了它,它就会失败,并出现以下错误:

/usr/lib/gcc/arm-none-eabi/4.8.2//libgcc.a(unwind-arm.o): In function `get_eit_entry':
/build/buildd/gcc-arm-none-eabi-6/build/arm-none-eabi/libgcc/../../../gcc-4.8.2/libgcc/unwind-arm-common.inc:221: undefined reference to `__exidx_end'
/build/buildd/gcc-arm-none-eabi-6/build/arm-none-eabi/libgcc/../../../gcc-4.8.2/libgcc/unwind-arm-common.inc:221: undefined reference to `__exidx_start'
/usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-abort.o): In function `abort':
/build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
/usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-signalr.o): In function `_kill_r':
/build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/signalr.c:61: undefined reference to `_kill'
/usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-signalr.o): In function `_getpid_r':
/build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/signalr.c:96: undefined reference to `_getpid'
/usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
/build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/sbrkr.c:58: undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status
make: *** [firmware.elf] Error 1

以下是失败的实际步骤:

arm-none-eabi-g++ -static -nostartfiles -ffreestanding -T ld_script -Wl,-O1,-Map=list.txt  ftl.o sata_identify.o sata_cmd.o sata_isr.o sata_main.o sata_table.o initialize.o mem_util.o flash.o flash_wrapper.o misc.o uart.o init.o -o firmware.elf -L"/usr/lib/gcc/arm-none-eabi/4.8.2/" -lgcc

有人可以建议修复吗?此外,如果我使用arm-none-eabi-gcc而不是arm-none-eabi-g ++,这种方法非常有效

1 个答案:

答案 0 :(得分:2)

您的问题是由编译器生成的异常处理代码引起的,该代码依赖于运行时组件 - 这些代码在您的构建中不存在。

-fno-exceptions关闭编译器代码生成中的异常处理。