如何处理失去的libgcc_.a

如何处理失去的libgcc_.a,c,compilation,flags,buildroot,libgcc,C,Compilation,Flags,Buildroot,Libgcc,使用外部工具链别名与buildroot交叉编译库 output/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lgcc_s collect2: ld returned 1 exit status 由于明显缺少libgcc_.a # find . -iname "libgcc*" .

使用外部工具链别名与buildroot交叉编译库

output/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
由于明显缺少
libgcc_.a

# find . -iname "libgcc*"        
./output/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libgcc_s.so
./output/host/usr/arm-buildroot-linux-gnueabi/sysroot/lib/libgcc_s.so.1
./output/host/opt/ext-toolchain/arm-none-linux-gnueabi/libc/armv4t/lib/libgcc_s.so.1
./output/host/opt/ext-toolchain/arm-none-linux-gnueabi/libc/armv4t/lib/libgcc_s.so
./output/host/opt/ext-toolchain/arm-none-linux-gnueabi/libc/thumb2/lib/libgcc_s.so.1
./output/host/opt/ext-toolchain/arm-none-linux-gnueabi/libc/thumb2/lib/libgcc_s.so
./output/host/opt/ext-toolchain/arm-none-linux-gnueabi/libc/lib/libgcc_s.so.1
./output/host/opt/ext-toolchain/arm-none-linux-gnueabi/libc/lib/libgcc_s.so
./output/host/opt/ext-toolchain/lib/gcc/arm-none-linux-gnueabi/4.6.1/armv4t/libgcc.a
./output/host/opt/ext-toolchain/lib/gcc/arm-none-linux-gnueabi/4.6.1/armv4t/libgcc_eh.a
./output/host/opt/ext-toolchain/lib/gcc/arm-none-linux-gnueabi/4.6.1/plugin/libgcc
./output/host/opt/ext-toolchain/lib/gcc/arm-none-linux-gnueabi/4.6.1/thumb2/libgcc.a
./output/host/opt/ext-toolchain/lib/gcc/arm-none-linux-gnueabi/4.6.1/thumb2/libgcc_eh.a
./output/host/opt/ext-toolchain/lib/gcc/arm-none-linux-gnueabi/4.6.1/libgcc.a
./output/host/opt/ext-toolchain/lib/gcc/arm-none-linux-gnueabi/4.6.1/libgcc_eh.a
有没有办法绕过这个问题,但仍然静态链接?是否有CLFAGS或LDFLAGS选项可以静态链接除
libgcc_s
之外的所有内容?

到目前为止尝试过的东西(除了阅读
ld
gcc
手册页的适用部分):


在添加
-Wl,-lgcc_s,-Bstatic
之后,我得到了大量未定义/未知的符号。。。(
-Bshared
不是有效选项)

/home/bernhard/buildroot-2013.08/output/target/usr/lib/libgio-2.0.a(libgio_2_0_la-glocalfileinfo.o):在函数“本地文件信息获取”中:
glocalfileinfo.c:(.text+0x2d90):警告:在静态链接的应用程序中使用“getgrgid”在运行时需要用于链接的glibc版本中的共享库
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libgio-2.0.a(libgio_2_0_la-glocalvfs.o):在函数“g_local_vfs_parse_name”中:
glocalvfs.c:(.text+0x174):警告:在静态链接的应用程序中使用“getpwnam”在运行时需要用于链接的glibc版本中的共享库
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libglib-2.0.a(libglib_2_0_la-gutils.o):在函数“g_get_user_database_entry”中:
gutils.c:(.text+0x254):警告:在静态链接的应用程序中使用“getpwuid”在运行时需要用于链接的glibc版本中的共享库
gutils.c:(.text+0x24c):警告:在静态链接的应用程序中使用“setpwent”在运行时需要用于链接的glibc版本中的共享库
gutils.c:(.text+0x25c):警告:在静态链接的应用程序中使用“endpwent”在运行时需要用于链接的glibc版本中的共享库
gutils.c:(.text+0xa0):警告:在静态链接的应用程序中使用“getpwnam_r”在运行时需要用于链接的glibc版本中的共享库
gutils.c:(.text+0xe0):警告:在静态链接的应用程序中使用“getpwuid\u r”在运行时需要用于链接的glibc版本中的共享库
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libgio-2.0.a(libgio_2_0_la-gnetworkaddress.o):在函数'g_network_address_parse_sockaddr'中:
gnetworkaddress.c:(.text+0x1ac):警告:在静态链接的应用程序中使用“getaddrinfo”在运行时需要用于链接的glibc版本中的共享库
>
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libxml2.a(xmlschemastypes.o):在函数“xmlschemagetcanovalue”中:
xmlschemastypes.c:(.text+0x7680):对“trunc”的未定义引用
xmlschemastypes.c:(.text+0x76bc):对“trunc”的未定义引用
xmlschemastypes.c:(.text+0x7710):对“floor”的未定义引用
xmlschemastypes.c:(.text+0x7760):对“floor”的未定义引用
collect2:ld返回了1个退出状态

可能可以取消使用带有标志的
libgcc_.a
,这些标志阻止
gcc
使用内部内置函数(例如它的内置memcpy),但您最好找到并使用它

看起来此选项应该阻止使用内置的
-fno-builtin
。有关更多详细信息,请参见此处:

与共享libgcc_.so链接

如果缺少
libgcc_.a
,或者需要将共享libgcc_.s与其他静态可执行文件一起使用,则应执行以下操作:

CFLAGS="-static -Wl,-Bdynamic,-lgcc_s,-Bstatic"

上面是find的输出,它在交叉编译器的安装路径中查找libgcc_(是的,它安装在buildroot目录中,该目录是当前的工作目录
),因此它似乎根本不存在……嗯,不知怎的,它跳过了那个目录。我会尝试
gcc-v
strace
来验证它是否尝试使用该特定路径。啊,仔细查看find输出-那里没有
libgccc_.a
,因此静态链接无法工作。您可以尝试动态链接它-我将更新答案以显示如何。啊,看起来它应该是
-Bdynamic
未共享的。第一次通过命令行上的位置拉入库时,它将决定如何包含它。如果设置了static,则它必须是静态的;如果是动态的,则它可以是动态的,也可以是静态的。因此,
-Bstatic-lx-Bdynamic-ly
只将x作为静态,将y作为静态。通常,为了强制一个库是静态的,我们会执行
-Bstatic-lx-Bdynamic
,这样就可以在前后添加其他参数,而不会破坏任何内容。
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libgio-2.0.a(libgio_2_0_la-glocalfileinfo.o): In function `_g_local_file_info_get':
glocalfileinfo.c:(.text+0x2d90): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libgio-2.0.a(libgio_2_0_la-glocalvfs.o): In function `g_local_vfs_parse_name':
glocalvfs.c:(.text+0x174): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libglib-2.0.a(libglib_2_0_la-gutils.o): In function `g_get_user_database_entry':
gutils.c:(.text+0x254): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
gutils.c:(.text+0x24c): warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
gutils.c:(.text+0x25c): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
gutils.c:(.text+0xa0): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
gutils.c:(.text+0xe0): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libgio-2.0.a(libgio_2_0_la-gnetworkaddress.o): In function `g_network_address_parse_sockaddr':
gnetworkaddress.c:(.text+0x1ac): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
<<<< SNIP >>>>
/home/bernhard/buildroot-2013.08/output/target/usr/lib/libxml2.a(xmlschemastypes.o): In function `xmlSchemaGetCanonValue':
xmlschemastypes.c:(.text+0x7680): undefined reference to `trunc'
xmlschemastypes.c:(.text+0x76bc): undefined reference to `trunc'
xmlschemastypes.c:(.text+0x7710): undefined reference to `floor'
xmlschemastypes.c:(.text+0x7760): undefined reference to `floor'
collect2: ld returned 1 exit status
CFLAGS="-static -Wl,-Bdynamic,-lgcc_s,-Bstatic"