我正在Linux上编写C ++库,库名是libic。 libic使用openssl。当我在主机Ubuntu 18.04上构建libic时,没有错误发生。但是当我为arm交叉编译libic时,构建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共享?感谢您的支持。
如果您的库依赖于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
希望这会有所帮助!