Mqtt is required in a project CPP, compile mqtt on the Cambrian box cpp。 mqtt. CPP is dependent on mqtt C library and header files, I first compiled mqtt c. Then compile mqtt During CPP, use the following cmake command to specify mqtt C library and header file location
cmake -DPAHO_WITH_SSL=OFF -DPAHO_MQTT_C_LIBRARIES=/home/chw/mqtt/paho.mqtt.c-master/install/lib64/libpaho-mqtt3a.so -DPAHO_MQTT_C_INCLUDE_DIRS=/home/chw/mqtt/paho.mqtt.c-master/install/include/ DCMAKE_INSTALL_PREFIX=../install ..
Then the following errors are reported during compilation
/home/chw/mqtt/paho.mqtt.c-master/install/lib64/libpaho-mqtt3a.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
src/CMakeFiles/paho-mqttpp3.dir/build.make:99: recipe for target 'src/libpaho-mqttpp3.so.1.2.0' failed
make[2]: *** [src/libpaho-mqttpp3.so.1.2.0] Error 1
CMakeFiles/Makefile2:89: recipe for target 'src/CMakeFiles/paho-mqttpp3.dir/all' failed
make[1]: *** [src/CMakeFiles/paho-mqttpp3.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
The first reaction to this error is that the format of the library linked by the LD command of arm is x86, so the prompt file in wrong format
Then I went to mqtt Under the install folder of C, use the file command to see the format of the library,
[email protected]:/home/chw/mqtt/paho.mqtt.c-master/install/lib64# file libpaho-mqtt3a.so.1.3.9
libpaho-mqtt3a.so.1.3.9: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
You can see that the format of this library is x86-64, and our Cambrian box is ARM architecture, so the format is not recognized. At this time, I suddenly found out how to mqtt There are lib and lib64 folders in the install folder of C, so I go to the Lib folder and use the file command to see the format.
[email protected]:/home/chw/mqtt/paho.mqtt.c-master/install/lib# file libpaho-mqtt3a.so.1.3.9
libpaho-mqtt3a.so.1.3.9: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=1875ae7550029980d276187e883c154aa43c7356, not stripped
I was pleasantly surprised to find that the Library under the Lib folder was in arm aarch64 format, so the cause of the problem was found. I used the Library under the lib64 folder when configuring cmake, so I used mqtt when configuring cmake The library path of C can be changed to Lib folder.
cmake -DPAHO_WITH_SSL=OFF -DPAHO_MQTT_C_LIBRARIES=/home/chw/mqtt/paho.mqtt.c-master/install/lib/libpaho-mqtt3a.so -DPAHO_MQTT_C_INCLUDE_DIRS=/home/chw/mqtt/paho.mqtt.c-master/install/include/ DCMAKE_INSTALL_PREFIX=../install ..
Also: compile mqtt.com below During the CPP library, it was found that the compiled library was also x86. Later, it was found that the reason was that I directly compiled mqtt on X86 The CPP # project was copied and then re cmake. I didn’t download the source code from GitHub again. After cmake, the compiled CPP library is in aarch64 format.
Problem solved!
Read More:
- [PX4 Bug] make px4_sitl gazebo Error: CMake Error: The following variables are used in this project
- [Solved] Mac Cmake Complie openmp Error: fatal error: ‘omp.h‘ file not found
- [Solved] mqttfx Error: Error Loading External CSS Resource
- Cmake Error The C compiler identification is GNU 7.5.0 — The CXX compiler identification is unknown
- [Solved] ROS fatal error: alsa/asoundlib. h: There is no such directory or file
- Clion new method shows undefined reference to solution
- [Solved] OpenGL PowerVR SDK Compiling Error: Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
- [Solved] error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows,
- [Solved] ORB_SLAM3 Compile Error: opencv4.0 not found four
- How to Solve QT and PCIe interactive loading setupapi.H error
- [Solved] CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
- [Solved] Failed to find glog – Could not find glog include directory, set…
- ORB-SLAM3 Compile Error: recipe for target ‘CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o‘ failed
- Cmake compile cocos2d-x error [How to Solve]
- [Solved] CMake Error: Error: generator : Unix Makefiles
- [Solved] Opencv Compile Error: (CMake Error: The following variables are used in this project, but they are set to not)
- [How to Fix]Unable to find the requested Boost libraries
- [Solved] VScode Run C++ File Error: fatal error:opencv2\core.hpp:No such file or diretory
- Cocoapods Upgrade Error: ffi * * * * [How to Solve]
- [Solved] PCL Compile Error: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>:: XXX