简体   繁体   English

与共享动态库交叉编译

[英]Cross compiling with shared dynamic libraries

In my C++ project, I'm compiling and linking against a library that makes use of OpenSSL.在我的 C++ 项目中,我正在编译和链接使用 OpenSSL 的库。

I need to compile this project for my BeagleBone which has openssl installed by default.我需要为我的 BeagleBone 编译这个项目,它默认安装了openssl I have downloaded libssl-dev on my development machine.我已经在我的开发机器上下载了libssl-dev

Thus, I can compile the project fine if I'm compiling for my development machine on x86_64 , but I am not able to successfully cross compile:因此,如果我在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

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 .这表明我需要有用于 OpenSSL 的armhf二进制文件,这似乎有点浪费,因为我的 BeagleBone 上有它们,如果它可以耐心等待直到我部署它

Is the only way around this cross-compiling OpenSSL myself?是我自己解决这种交叉编译 OpenSSL 的唯一方法吗? Where would I then need to install the .so files (I guess make install would be a bad idea?)然后我需要在哪里安装.so文件(我想make install是个坏主意?)

This indicates I need to have armhf binaries for OpenSSL这表明我需要为 OpenSSL 提供 armhf 二进制文件

Correct.正确的。

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.这似乎有点浪费,因为我将它们放在我的 BeagleBone 上,如果它可以耐心等待我部署它。

You appear to think that shared libraries are only needed at runtime, but that is not the case.您似乎认为只有在运行时才需要共享库,但事实并非如此。

ELF stands for executable and linking format. ELF代表可执行和链接格式。 The .so is very much needed at static link time to construct various tables in the main executable, which will then be used by the loader at runtime to resolve references from the main executable to the .so . .so在静态链接时非常需要在主可执行文件中构造各种表,然后加载程序在运行时使用这些表来解析从主可执行文件到.so引用。

If you are familiar with Win32, you can think of .so as a combination of Win32 .LIB and .DLL packed into a single file.如果您熟悉 Win32,您可以将.so视为打包到单个文件中的 Win32 .LIB.DLL的组合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM