在我的 C++ 项目中,我正在编译并链接一个使用 OpenSSL 的库。
我需要为默认安装了 openssl
的 BeagleBone 编译此项目。我已在我的开发计算机上下载了 libssl-dev
。
因此,如果我在 x86_64
上为我的开发机器进行编译,我可以很好地编译该项目,但我无法成功交叉编译:
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lssl
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lcrypto
这表明我需要 OpenSSL 的 armhf
二进制文件,这似乎有点浪费,因为我将它们放在我的 BeagleBone 上,如果它可以耐心等待我部署它。
这是我自己交叉编译 OpenSSL 的唯一方法吗?然后我需要在哪里安装 .so
文件(我猜 make install
是一个坏主意?)
最佳答案
This indicates I need to have armhf binaries for OpenSSL
正确。
which seems a bit of a waste really since I have them on my BeagleBone if it can just be patient and wait until I deploy it.
您似乎认为共享库仅在运行时需要,但事实并非如此。
ELF
代表可执行和链接格式。在静态链接时非常需要 .so
来在主可执行文件中构造各种表,然后加载程序在运行时使用这些表来解析从主可执行文件到 的引用。所以
。
如果您熟悉 Win32,您可以将 .so
视为 Win32 .LIB
和 .DLL
的组合,打包到一个单个文件。
关于c++ - 与共享动态库交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32789598/