【问题标题】:How to cross compile Paho-MQTT-C library for ARM?如何为 ARM 交叉编译 Paho-MQTT-C 库?
【发布时间】:2018-09-28 15:00:04
【问题描述】:

如何为 ARM 平台交叉编译 Paho-MQTT C 库。

这是我遵循的步骤。

1) Downloaded library from  [Paho-MQTT-C][1]
2) after download, I opened the directory and entered some commands.
3) command for setting the GCC-ARM tool chain (environment variable_path)
4) make CC=(ARM-CROSS_COMPILE)gcc

接下来,我观察到以下错误

mkdir -p build/output/samples
mkdir -p build/output/test
echo OSTYPE is Linux
OSTYPE is Linux
sed -e "s/@CLIENT_VERSION@/1.2.0/g" -e "s/@BUILD_TIMESTAMP@/Mon Apr 16 17:13:10 IST 2018/g" src/VersionInfo.h.in > build/VersionInfo.h
arm-cortexa9-linux-gnueabihf-gcc -g -fPIC  -Os -Wall -fvisibility=hidden -Ibuild -o build/output/libpaho-mqtt3c.so.1.0 src/MQTTPersistence.c src/Heap.c src/Socket.c src/MQTTProtocolClient.c src/MQTTProtocolOut.c src/StackTrace.c src/MQTTPersistenceDefault.c src/MQTTClient.c src/Messages.c src/MQTTPacketOut.c src/Clients.c src/OsWrapper.c src/Thread.c src/MQTTPacket.c src/Log.c src/LinkedList.c src/utf-8.c src/SocketBuffer.c src/Tree.c  -shared -Wl,-init,MQTTClient_init -lpthread -Wl,-soname,libpaho-mqtt3c.so.1
ln -s libpaho-mqtt3c.so.1.0  build/output/libpaho-mqtt3c.so.1
ln -s libpaho-mqtt3c.so.1 build/output/libpaho-mqtt3c.so
arm-cortexa9-linux-gnueabihf-gcc -g -fPIC  -Os -Wall -fvisibility=hidden -Ibuild -o build/output/libpaho-mqtt3cs.so.1.0 src/MQTTPersistence.c src/Heap.c src/Socket.c src/SSLSocket.c src/MQTTProtocolClient.c src/MQTTProtocolOut.c src/StackTrace.c src/MQTTPersistenceDefault.c src/MQTTClient.c src/Messages.c src/MQTTPacketOut.c src/Clients.c src/OsWrapper.c src/Thread.c src/MQTTPacket.c src/Log.c src/LinkedList.c src/utf-8.c src/SocketBuffer.c src/Tree.c -DOPENSSL  -shared -Wl,--start-group -lpthread -ldl -lssl -lcrypto -Wl,--end-group -Wl,-init,MQTTClient_init -Wl,-soname,libpaho-mqtt3cs.so.1 -Wl,-no-whole-archive
In file included from src/MQTTPersistence.h:23:0,
             from src/MQTTPersistence.c:28:
src/Clients.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/Socket.c:32:0:
src/SocketBuffer.h:28:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/SSLSocket.c:31:0:
src/SocketBuffer.h:28:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/MQTTPacket.h:25:0,
             from src/MQTTProtocolClient.h:25,
             from src/MQTTProtocolClient.c:34:
src/SSLSocket.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/MQTTPacket.h:25:0,
             from src/MQTTProtocolOut.h:24,
             from src/MQTTProtocolOut.c:35:
src/SSLSocket.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/StackTrace.c:21:0:
src/Clients.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/MQTTPersistence.h:23:0,
             from src/MQTTClient.c:53:
src/Clients.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/MQTTPacket.h:25:0,
             from src/MQTTPacketOut.h:22,
             from src/MQTTPacketOut.c:29:
src/SSLSocket.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/Clients.c:24:0:
src/Clients.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/MQTTPacket.h:25:0,
             from src/MQTTPacket.c:26:
src/SSLSocket.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/MQTTPacket.h:25:0,
             from src/Log.c:27:
src/SSLSocket.h:29:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
In file included from src/SocketBuffer.c:25:0:
src/SocketBuffer.h:28:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.
Makefile:219: recipe for target 'build/output/libpaho-mqtt3cs.so.1.0' failed
make: *** [build/output/libpaho-mqtt3cs.so.1.0] Error 1

4) 我使用这个命令安装了 openssl

$ sudo apt-get install libssl-dev*

Openssl 安装成功,但还是出现上述错误。

为 ARM 编译 Paho-MQTT-C 库需要做什么?

【问题讨论】:

  • 嗯,你为什么还要手动交叉编译它?cgit.openembedded.org/meta-openembedded/tree/meta-oe/… 有一个 OpenEmbedded 配方可供你使用(因为你的标签表明你想运行“yocto”,例如基于OE的poky分布)
  • 实际上 Yocto 已经安装在我的板上,我正在尝试为 ARM 交叉编译我的(基于 C 的)项目。我正在使用 Paho-C 库进行 MQTT 连接,它在内部使用 openssl/ssl.h 文件进行操作。 @LetoThe2nd

标签: cross-compiling embedded-linux mqtt yocto paho


【解决方案1】:

在 cmets 中给出您的问题和解释的正确解决方案如下:

  1. 在您的板上重建映像并使其包含 paho-mqtt-c 包。这可以通过图像配方中的 IMAGE_INSTALL 变量来完成,或者如果您想通过 local.conf 等注入它,则可以通过 CORE_IMAGE_EXTRA_INSTALL 来完成。

  2. 交叉编译,生成合适的SDK:bitbake -c populate_sdk YOUR_IMAGE

  3. 使用该内置 sdk 编译您​​的软件。这在第 8 章和第 9 章中有详细记录:https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#sdk-using-the-standard-sdk

您也可以选择:

  1. 为您的应用程序创建一个配方并直接通过 bitbake 构建它。有配方 DEPENDS += "paho-mqtt-c",那么一切都应该自动处理。

  2. 出于开发目的,您可以按照此处所述从实时开发源代码树构建:https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#building-software-from-an-external-source

【讨论】:

    【解决方案2】:

    如果您已经在使用基于 Yocto 的构建,那么您可以考虑集成层 meta-intel-iot-middleware

    meta-intel-iot-middleware 层为paho-mqtt 3.1 提供了一个可用的配方。您可以使用 IMAGE_INSTALL 将其包含在内。

    【讨论】:

      猜你喜欢
      • 2021-07-26
      • 2018-03-17
      • 2013-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-19
      • 1970-01-01
      • 2019-05-21
      相关资源
      最近更新 更多