无法使用Openwrt工具链构建静态二进制文件:对_Unwind_Resume和__gcc_personality_v0的未定义引用

时间:2016-11-07 12:28:03

标签: c gcc static-libraries openwrt gnu-toolchain

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

 PyCharm Community Edition 2016.2.3   (Ubuntu 16.04)
 ipython                   5.1.0                    py35_0  
 jupyter                   1.0.0                    py35_3  
 notebook                  4.2.3                    py35_0  

我的主机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 -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

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

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

如在Internet上的其他地方找到的那样,将-lgcc_eh添加到链接器标志也没有帮助。

1 个答案:

答案 0 :(得分:3)

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

作品