gpt4 book ai didi

c - 无法使用 Openwrt 工具链 : Undefined reference to _Unwind_Resume and __gcc_personality_v0 构建静态二进制文件

转载 作者:太空宇宙 更新时间:2023-11-04 06:59:21 27 4
gpt4 key购买 nike

我无法使用 openwrt 工具链构建静态二进制文件。

# staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/bin/i486-openwrt-linux-gnu-gcc -o /tmp/main /tmp/main.c -static
/tmp/main.c: In function 'main':
/tmp/main.c:3:2: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
printf("Hello world");
^
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iofclose.o): In function `_IO_new_fclose':
iofclose.c:(.text+0x1a6): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iofclose.o):(.eh_frame+0x13): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iofflush.o): In function `_IO_fflush':
iofflush.c:(.text+0xe9): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iofflush.o):(.eh_frame+0x13): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(wfileops.o): In function `_IO_wfile_underflow':
wfileops.c:(.text+0x4e6): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(wfileops.o):(.eh_frame+0x5b): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(fileops.o): In function `_IO_new_file_underflow':
fileops.c:(.text+0x361): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(fileops.o):(.eh_frame+0xe7): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(backtrace.o): In function `backtrace_helper':
backtrace.c:(.text+0x21): undefined reference to `_Unwind_GetIP'
backtrace.c:(.text+0x43): undefined reference to `_Unwind_GetGR'
backtrace.c:(.text+0x4e): undefined reference to `_Unwind_GetCFA'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(backtrace.o): In function `__backtrace':
backtrace.c:(.text+0x9a): undefined reference to `_Unwind_Backtrace'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iofputs.o): In function `_IO_fputs':
iofputs.c:(.text+0x107): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iofputs.o):(.eh_frame+0x13): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iogetdelim.o): In function `_IO_getdelim':
iogetdelim.c:(.text+0x22b): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(iogetdelim.o):(.eh_frame+0x13): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(fseek.o): In function `fseek':
fseek.c:(.text+0xe2): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(fseek.o):(.eh_frame+0x13): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(ftello.o): In function `__ftello':
ftello.c:(.text+0x13c): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(ftello.o):(.eh_frame+0x13): undefined reference to `__gcc_personality_v0'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(ioseekoff.o): In function `_IO_seekoff':
ioseekoff.c:(.text+0x1ab): undefined reference to `_Unwind_Resume'
/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/../../../../i486-openwrt-linux-gnu/lib/libc.a(ioseekoff.o):(.eh_frame+0x67): undefined reference to `__gcc_personality_v0'
collect2: error: ld returned 1 exit status

我的主机 gcc 是 Debian 8 上的 4.9.2 版。我使用以下配置构建了 openwrt 工具链:

GCC 编译器版本:具有 Linaro 增强功能的 gcc 4.8.x

C 库实现:使用 (e)glibc

(e)glibc 版本:glibc 2.21

工具链信息:

# staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/bin/i486-openwrt-linux-gnu-gcc -v
Reading specs from /home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib/gcc/i486-openwrt-linux-gnu/4.8.3/specs
COLLECT_GCC=staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/bin/i486-openwrt-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/libexec/gcc/i486-openwrt-linux-gnu/4.8.3/lto-wrapper
Target: i486-openwrt-linux-gnu
Configured with: /home/elison/cop-poc/copernicus-openwrt/build_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/gcc-linaro-4.8-2014.04/configure --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt/Linaro GCC 4.8-2014.04 unknown' --prefix=/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21 --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=i486-openwrt-linux-gnu --with-gnu-ld --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-multilib --disable-nls --with-host-libstdcxx=-lstdc++ --with-gmp=/home/elison/cop-poc/copernicus-openwrt/staging_dir/host --with-mpfr=/home/elison/cop-poc/copernicus-openwrt/staging_dir/host --with-mpc=/home/elison/cop-poc/copernicus-openwrt/staging_dir/host --disable-decimal-float --disable-libssp --enable-__cxa_atexit --with-headers=/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/include --disable-libsanitizer --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/home/elison/cop-poc/copernicus-openwrt/staging_dir/toolchain-i386_i686_gcc-4.8-linaro_glibc-2.21/lib
Thread model: posix
gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 unknown)

这里提到的答案没有帮助: https://stackoverflow.com/a/22774664/879142

添加 --enable-static 作为额外的 gcc 配置选项也无济于事。

正如在 Internet 上的其他地方发现的那样,将 -lgcc_eh 添加到链接器标志也无济于事。

最佳答案

aarch64-openwrt-linux-gcc thread.c -static -lpthread -lc -lgcc_eh

作品

关于c - 无法使用 Openwrt 工具链 : Undefined reference to _Unwind_Resume and __gcc_personality_v0 构建静态二进制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40465212/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com