当前位置:   article > 正文

PAHO MQTT交叉编译_libpaho-mqtt3c

libpaho-mqtt3c

1. 下载

git clone https://github.com/eclipse/paho.mqtt.c

2. 编译

a. 在 cmake/ 下创建一个自己的 交叉编译链 cmake 文件 toolchain.linux-aaa.cmake

  1. # path to compiler and utilities
  2. # specify the cross compiler
  3. SET(CMAKE_C_COMPILER aaa-gnu-gcc)
  4. SET(CMAKE_CXX_COMPILER aaa-gnu-g++)
  5. SET(CMAKE_INSTALL_PREFIX /work/MQTT/paho.mqtt.c/build/output)
  6. # Name of the target platform
  7. SET(CMAKE_SYSTEM_NAME Linux)
  8. SET(CMAKE_SYSTEM_PROCESSOR aaa)
  9. #openssl
  10. SET(OPENSSL_ROOT_DIR /work/MQTT/openssl-1.1.1g-libs/Bin)
  11. SET(OPENSSL_LIBRARIES /work/MQTT/openssl-1.1.1g-libs/Bin/lib)
  12. SET(OPENSSL_INCLUDE_DIR /work/MQTT/openssl-1.1.1g-libs/Bin/include)
  13. # Version of the system
  14. SET(CMAKE_SYSTEM_VERSION 1)

非交叉编译版本

  1. # path to compiler and utilities
  2. # specify the cross compiler
  3. #SET(CMAKE_C_COMPILER aaa-gnu-gcc)
  4. #SET(CMAKE_CXX_COMPILER aaa-gnu-g++)
  5. SET(CMAKE_INSTALL_PREFIX /work/MQTT/paho.mqtt.c/build-gcc/output)
  6. # Name of the target platform
  7. #SET(CMAKE_SYSTEM_NAME Linux)
  8. #SET(CMAKE_SYSTEM_PROCESSOR aaa)
  9. #openssl
  10. SET(OPENSSL_ROOT_DIR /work/MQTT/openssl-1.1.1g-libs-gcc/Bin)
  11. SET(OPENSSL_LIBRARIES /work/MQTT/openssl-1.1.1g-libs-gcc/Bin/lib)
  12. SET(OPENSSL_INCLUDE_DIR /work/MQTT/openssl-1.1.1g-libs-gcc/Bin/include)
  13. # Version of the system
  14. SET(CMAKE_SYSTEM_VERSION 1)

b.

  1. $ mkdir build && cd build
  2. $ cmake .. \
  3. -DPAHO_WITH_SSL=TRUE \
  4. -DPAHO_BUILD_SAMPLES=TRUE \
  5. -DCMAKE_TOOLCHAIN_FILE=/work/MQTT/paho.mqtt.c/cmake/toolchain.linux-aaa.cmake
  6. $ make -j8
  7. $ make install

编译结果在 build/output 下了:

  1. $ ll output/lib/
  2. 总用量 1104
  3. drwxrwxr-x 3 4096 716 15:52 ./
  4. drwxrwxr-x 6 4096 716 15:52 ../
  5. drwxrwxr-x 3 4096 716 15:52 cmake/
  6. lrwxrwxrwx 1 19 716 15:52 libpaho-mqtt3a.so -> libpaho-mqtt3a.so.1
  7. lrwxrwxrwx 1 23 716 15:52 libpaho-mqtt3a.so.1 -> libpaho-mqtt3a.so.1.3.9
  8. -rw-r--r-- 1 277154 716 15:52 libpaho-mqtt3a.so.1.3.9
  9. lrwxrwxrwx 1 20 716 15:52 libpaho-mqtt3as.so -> libpaho-mqtt3as.so.1
  10. lrwxrwxrwx 1 24 716 15:52 libpaho-mqtt3as.so.1 -> libpaho-mqtt3as.so.1.3.9
  11. -rw-r--r-- 1 312241 716 15:52 libpaho-mqtt3as.so.1.3.9
  12. lrwxrwxrwx 1 19 716 15:52 libpaho-mqtt3c.so -> libpaho-mqtt3c.so.1
  13. lrwxrwxrwx 1 23 716 15:52 libpaho-mqtt3c.so.1 -> libpaho-mqtt3c.so.1.3.9
  14. -rw-r--r-- 1 244128 716 15:52 libpaho-mqtt3c.so.1.3.9
  15. lrwxrwxrwx 1 20 716 15:52 libpaho-mqtt3cs.so -> libpaho-mqtt3cs.so.1
  16. lrwxrwxrwx 1 24 716 15:52 libpaho-mqtt3cs.so.1 -> libpaho-mqtt3cs.so.1.3.9
  17. -rw-r--r-- 1 277527 716 15:52 libpaho-mqtt3cs.so.1.3.9

c. 出错信息

没有安装 doxygen 时,cmake 后会报以下信息:

"Doxygen is needed to build the documentation."

安装 doxygen:

$ sudo apt-get install doxygen-latex  doxygen-doc doxygen-gui graphviz

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/200772?site
推荐阅读
相关标签
  

闽ICP备14008679号