我在Linux上编写了一个C++库,库的名字是libic。libic使用openssl。当我在主机Ubuntu 18.04上构建libic时,没有出现错误。但是当我交叉编译libic for arm时,在构建libic共享目标时出现链接器错误。错误信息如下:
....
[100%] Linking CXX shared library libic.so
uclient.c:(.text+0xd96): undefined reference to `event_del'
uclient.c:(.text+0xd9e): undefined reference to `event_free'
uclient.c:(.text+0xdae): undefined reference to `event_del'
uclient.c:(.text+0xdb6): undefined reference to `event_free'
uclient.c:(.text+0xdf8): undefined reference to `SSL_get_shutdown'
uclient.c:(.text+0xe0a): undefined reference to `SSL_free'
uclient.c:(.text+0xe5c): undefined reference to `SSL_free'
uclient.c:(.text+0xe90): undefined reference to `event_base_free'
uclient.c:(.text+0xe98): undefined reference to `pthread_cancel'
uclient.c:(.text+0xed6): undefined reference to `SSL_get_shutdown'
uclient.c:(.text+0xefa): undefined reference to `SSL_set_shutdown'
uclient.c:(.text+0xf06): undefined reference to `SSL_shutdown'
uclient.c:(.text+0xf12): undefined reference to `SSL_set_shutdown'
uclient.c:(.text+0xf1a): undefined reference to `SSL_shutdown'配置日志如下
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found OpenSSL: /home/drone/tizen-studio/platforms/tizen-3.0/mobile/rootstraps/mobile-3.0-device.core/usr/lib/libcrypto.so (found version "1.0.2k")
-- Using OpenSSL 1.0.2k
-- Found CURL: /home/drone/tizen-studio/platforms/tizen-3.0/mobile/rootstraps/mobile-3.0-device.core/usr/lib/libcurl.so (found version "7.50.2")
--
-- C/C++:
-- C++ Compiler: /home/drone/Downloads/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ (ver 7.3.1)
-- C++ flags (Release): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -std=c++1y -fPIC -O3 -DNDEBUG
-- C++ flags (Debug): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -std=c++1y -fPIC -g
-- C Compiler: /home/drone/Downloads/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc
-- C flags (Release): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -O3 -DNDEBUG
-- C flags (Debug): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -g
-- CMAKE_INSTALL_PREFIX: /home/drake/Documents/code/libscs/packages/libscs
-- Linker flags (Release): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
-- Linker flags (Debug): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now 似乎在交叉编译的情况下,libic需要链接到openssl。我想问的是,如果不使用openssl链接,我如何构建libic共享?多谢你们的支持。
发布于 2020-02-04 11:18:43
如果你的库依赖于libssl,你不能在没有链接到libssl的情况下编译它。您是否尝试过获取用于arm体系结构的libssl包?从我的脑海中浮现出来的东西
dpkg --add-architecture arm
apt update
apt install libssl-dev:arm或者也许
dpkg --add-architecture arm64
apt update
apt install libssl-dev:arm64希望这能有所帮助!
发布于 2020-02-08 10:41:23
谢谢你们,我已经找到了答案,链接器问题的发生是因为这个链接器标志-Wl,--不--未定义。只需删除此链接器选项即可
https://stackoverflow.com/questions/60049817
复制相似问题