简体   繁体   English

为什么我的一个 finaries 失败,找不到版本“GLIBC_2.27”

[英]Why does one of my finaries fail with version `GLIBC_2.27' not found

I am cross-compiling by binaries identically by CMake clauses like我正在通过二进制文件交叉编译CMake子句,例如

add_executable(mybinary1 mybinary1.c util_temp.c)
target_link_libraries(mybinary1 m)

add_executable(mybinary2 mybinary2.c util_temp.c)
target_link_libraries(mybinary2 m)

Unfortunately, one of them fails when running on target platform:不幸的是,其中一个在目标平台上运行时失败了:

/mybinary2: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by ./mybinary2)

First binary runs well.第一个二进制运行良好。

ldd shows ldd显示

# ldd mybinary2
./mybinary2: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by ./mybinary2)
    linux-vdso.so.1 (0x7ed1d000)
    /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76fa2000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76f27000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76de6000)
    /lib/ld-linux-armhf.so.3 (0x76fcc000)
# ldd mybinary1
    linux-vdso.so.1 (0x7ee09000)
    /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76ece000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76e53000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76d12000)
    /lib/ld-linux-armhf.so.3 (0x76efb000)

What does it mean and how to solve it?这是什么意思,如何解决? Can I compile against specific version of a library?我可以针对特定版本的库进行编译吗? Why does it refer GLIBS indirectly, via libm ?为什么它通过libm间接引用GLIBS

If I do如果我做

target_link_libraries(mybinary2 m -static)

it starts to work but binary becomes x20 larger.它开始工作,但二进制文件变大了 20 倍。

I also tried我也试过

__asm__(".symver realpath,realpath@GLIBC_2.19");
int main(int argc, char *argv[])

in mybinary2.c with no effect.mybinary2.c中无效。

target_link_libraries(mybinary2 m -static-libgcc -static-libstdc++)

in CMakeLists.txt with no effect.CMakeLists.txt中无效。

target_link_libraries(mybinary2 m libc.so.6:2.19)

with error message有错误讯息

[build] /usr/lib/gcc-cross/arm-linux-gnueabihf/7/../../../../arm-linux-gnueabihf/bin/ld: cannot find -llibc.so.6:2.19

Is latter syntax correct?后一种语法正确吗? How to see, which version (and of what) is on my system?如何查看我的系统上有哪个版本(以及什么版本)?

I tried commands like我试过像这样的命令

ld -llibc

but neither work.但都不起作用。

On my target computer (it is Raspberry Pi with old version of OS):在我的目标计算机上(它是具有旧版本操作系统的 Raspberry Pi):

# ldd --version
ldd (Debian GLIBC 2.19-18+deb8u10) 2.19
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

I don't know how to use cross ldd on source computer.我不知道如何在源计算机上使用 cross ldd

Based on what your target computer outputs via ldd --version and based on the error (which also explains why a static link works):基于您的目标计算机通过ldd --version输出的内容和错误(这也解释了为什么 static 链接有效):

You have a GLIBC version mismatch, ie you compile it using GLIBC 2.27 but on the target computer you have GLIBC 2.19 .您的 GLIBC 版本不匹配,即您使用GLIBC 2.27编译它,但在目标计算机上您有GLIBC 2.19 You either need to crosscompile with a lower version than you are currently using or upgrade glibc on the target computer.您要么需要使用比当前使用的版本更低的版本进行交叉编译,要么需要在目标计算机上升级glibc

EDIT: To clarify which errors and general info I mean:编辑:为了澄清我的意思是哪些错误和一般信息:

1) 1)

# ldd mybinary2
./mybinary2: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by ./mybinary2)
# ldd --version
ldd (Debian GLIBC 2.19-18+deb8u10) 2.19

EDIT2: Did a quick search and assuming you are crosscompiling on debian you could use the following command to get available package versions: EDIT2:快速搜索并假设您在 debian 上交叉编译,您可以使用以下命令获取可用的 package 版本:

apt-cache policy myPackage

Where myPackage will most likely be libc6-dev-armhf-cross for your current needs. myPackage最有可能是libc6-dev-armhf-cross以满足您当前的需求。

EDIT3: As Andrew Henle pointed out. EDIT3:正如 Andrew Henle 指出的那样。 The easiest solution is to directly compile your project on the target device (or a compilation environment that is identical to the one on the target).最简单的解决方案是直接在目标设备(或与目标设备相同的编译环境)上编译您的项目。 Consider the above only if the target device is limiting you in doing so.仅当目标设备限制您这样做时才考虑上述内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM