正如主题所说,我使用GCC 4.7.2编译我的C项目,它显示如下错误:
ext_kernel/ext_kernel.a(align.o):(.eh_frame+0x13): undefined reference to `__gcc_personality_v0'
kernel/kernel.a(os_core.o): In function `OS_TaskStatStkChk':
/mnt/G10/dcs1/newp/Heros_dev/kernel/os_core.c:1195: undefined reference to `_Unwind_Resume'
kernel/kernel.a(os_core.o): In function `OS_TCBInit':
/mnt/G10/dcs1/newp/Heros_dev/kernel/os_core.c:1352: undefined reference to `_Unwind_Resume'
kernel/kernel.a(os_core.o):(.eh_frame+0x343): undefined reference to `__gcc_personality_v0'
然后我检查并修改我的代码,我发现错误源代码如下:
void func()
{
char str1[10];
printf("");
}
只有当我声明一个复杂的数据类型(如数组,结构等)并调用函数时,才会发生此错误。但是当我使用gcc单独编译C文件时,不会发生此错误。 我使用的gcc如下:
root@ubuntu:Heros_dev# powerpc-unknown-linux-gnuspe-gcc -v
Using built-in specs.
COLLECT_GCC=powerpc-unknown-linux-gnuspe-gcc
COLLECT_LTO_WRAPPER=/mnt/fs/Cross_Tools/gcc-4.7.2-XMe500v2-linuxspe/bin/../libexec/gcc/powerpc-unknown-linux-gnuspe/4.7.2/lto-wrapper
Target: powerpc-unknown-linux-gnuspe
Configured with: ../src_gcc/configure --target=powerpc-unknown-linux-gnuspe --with-long-double-128 --enable-poison-system-directories --with-gnu-as --with-gnu-ld --disable-libstdcxx-pch --disable-libssp --disable-libmudflap --disable-bootstrap --disable-libquadmath --disable-nls --enable-symvers=gnu --enable-__cxa_atexit --enable-threads --prefix=/pkg/fs-DTgnu-/gcc-4.7.2-XMe500v2-linuxspe/i686-linux --with-sysroot=/pkg/fs-DTgnu-/gcc-4.7.2-XMe500v2-linuxspe/i686-linux/powerpc-unknown-linux-gnuspe/libc --with-build-sysroot=/tmp/edmar/release//pkg/fs-DTgnu-/gcc-4.7.2-XMe500v2-linuxspe/i686-linux/powerpc-unknown-linux-gnuspe/libc --with-build-time-tools=/tmp/edmar/release//pkg/fs-DTgnu-/gcc-4.7.2-XMe500v2-linuxspe/i686-linux/powerpc-unknown-linux-gnuspe/bin --enable-languages=c,c++,fortran --with-cpu=8548 --enable-e500_double --with-host-libstdcxx='-static-libgcc -static -Wl,-Bstatic,-lstdc++ -lm' --with-gmp=/tmp/edmar/release//pkg/fs-DTgnu-/XLMe500v2/linux_host_libs/usr --with-mpfr=/tmp/edmar/release//pkg/fs-DTgnu-/XLMe500v2/linux_host_libs/usr --with-mpc=/tmp/edmar/release//pkg/fs-DTgnu-/XLMe500v2/linux_host_libs/usr --with-ppl=/tmp/edmar/release//pkg/fs-DTgnu-/XLMe500v2/linux_host_libs/usr --with-cloog=/tmp/edmar/release//pkg/fs-DTgnu-/XLMe500v2/linux_host_libs/usr --enable-cloog-backend=isl
Thread model: posix
gcc version 4.7.2 20120920 (Fri Mar 29 11:44:41 CDT 2013 build.sh rev=817 s=F472 -i /pkg/fs-DTgnu- t=DGREMspe XLMe500v2 -V release-CDE-r817_Lcross_F472_XLMe500v2) (GCC)
linux是Ubuntu 12.04。