在 C 上编译 ARM 的错误消息:指向 «crc32» 的未定义链接



我尝试编译ARM 32位一个C项目,包含到zlib的链接,minizip静态库。我在Ubuntu 20上使用CLion IDE。我已经安装了toolchain:

sudo apt-get install gcc-arm-linux-gnueabihf

然后我下载了ARM的deb包,从中我提取了libz.a,libminizip.a:

zlib1g-dev_1.2.11.dfsg-2ubuntu1_armhf.deb
libminizip-dev_1.1-8build1_armhf.deb

然后我试着编译,但是有:

====================[ Build | all | Default-System ]============================
/home/user/external/clion-2023.1.1/bin/cmake/linux/x64/bin/cmake --build /home/user/Clion/myproject/cmake-build-default-system --target all -j 1
[3/3] Linking C executable updater
FAILED: updater 
: && /usr/bin/arm-linux-gnueabihf-gcc -fsanitize=address  CMakeFiles/updater.dir/main.c.o CMakeFiles/updater.dir/base64.c.o -o updater  /home/user/Clion/myproject/lib/arm/libz.a  /home/user/Clion/myproject/lib/arm/libminizip.a  /home/user/Clion/myproject/lib/arm/libjansson.a && :
/usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /home/user/Clion/myproject/lib/arm/libminizip.a(unzip.o): in function «unzReadCurrentFile»:
(.text+0x144e): undefined link to «crc32»

这里是CmakeLists.txt:

cmake_minimum_required(VERSION 3.17)
project(updater C)
set(CMAKE_C_STANDARD 99)
add_executable(updater main.c unpack.h)

set(ZLIB_INCLUDE_DIR /home/user/Clion/myproject/zlib-arm/include)
set(ZLIB_LIBRARY /home/user/Clion/myproject/lib/arm/libz.a)
set(MINIZIP_LIBRARY /home/user/Clion/myproject/lib/arm/libminizip.a)
target_include_directories(updater PRIVATE ${ZLIB_INCLUDE_DIR})
target_link_libraries(updater PRIVATE ${ZLIB_LIBRARY})
target_link_libraries(updater PRIVATE ${MINIZIP_LIBRARY})

对libz的调查。a似乎没问题:

nm /home/user/Clion/myproject/lib/arm/libz.a | grep crc32
crc32.o:
00000645 T crc32
0000064d T crc32_combine
00000481 t crc32_combine_
00000651 T crc32_combine64
00000001 t crc32_little
0000063d T crc32_z
U crc32
U crc32
我怀疑下载的库可能不兼容。但是用什么来代替它们呢?或者手动构建它们——但是如何构建呢?任何建议吗?

您的链接命令:

arm-linux-gnueabihf-gcc ... libz.a libminizip.a ...

是不正确的:因为libminzip.a需要libz.a的符号,所以在链接行libz.a之前应该是

要更好地理解这一点,请阅读这篇文章。

相关内容

  • 没有找到相关文章

最新更新