簡體   English   中英

為什么我的一個 finaries 失敗,找不到版本“GLIBC_2.27”

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

我正在通過二進制文件交叉編譯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)

不幸的是,其中一個在目標平台上運行時失敗了:

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

第一個二進制運行良好。

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)

這是什么意思,如何解決? 我可以針對特定版本的庫進行編譯嗎? 為什么它通過libm間接引用GLIBS

如果我做

target_link_libraries(mybinary2 m -static)

它開始工作,但二進制文件變大了 20 倍。

我也試過

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

mybinary2.c中無效。

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

CMakeLists.txt中無效。

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

有錯誤訊息

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

后一種語法正確嗎? 如何查看我的系統上有哪個版本(以及什么版本)?

我試過像這樣的命令

ld -llibc

但都不起作用。

在我的目標計算機上(它是具有舊版本操作系統的 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.

我不知道如何在源計算機上使用 cross ldd

基於您的目標計算機通過ldd --version輸出的內容和錯誤(這也解釋了為什么 static 鏈接有效):

您的 GLIBC 版本不匹配,即您使用GLIBC 2.27編譯它,但在目標計算機上您有GLIBC 2.19 您要么需要使用比當前使用的版本更低的版本進行交叉編譯,要么需要在目標計算機上升級glibc

編輯:為了澄清我的意思是哪些錯誤和一般信息:

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:快速搜索並假設您在 debian 上交叉編譯,您可以使用以下命令獲取可用的 package 版本:

apt-cache policy myPackage

myPackage最有可能是libc6-dev-armhf-cross以滿足您當前的需求。

EDIT3:正如 Andrew Henle 指出的那樣。 最簡單的解決方案是直接在目標設備(或與目標設備相同的編譯環境)上編譯您的項目。 僅當目標設備限制您這樣做時才考慮上述內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM