eclipse-paho / eclipse-paho/paho.mqtt.cpp
Cross compiling error: "Could NOT find PahoMqttC (missing: PAHO_MQTT_C_LIBRARIES PAHO_MQTT_C_INCLUDE_DIRS)"
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 475
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to cross compile the mqtt C++ lib to use in my embedded linux device ( An armv7l device), then I add as a submodule [paho.mqtt.cpp](https://github.com/eclipse/paho.mqtt.cpp) and also [paho.mqtt.c](https://github.com/eclipse/paho.mqtt.c) and inside my project I created a lib folder to be installed all my dependencies. Basicaly, I ran:
In my project root folder:
```bash
$ mkdir lib
$ cd lib
$ git submodule add git@github.com:eclipse/paho.mqtt.cpp.git
$ git submodule add git@github.com:eclipse/paho.mqtt.c.git
$ mkdir -p mqtt/paho.mqtt.cpp
$ mkdir -p mqtt/paho.mqtt.c
```
Then I configure, compile and install sucefully `paho.mqtt.c` inside mqtt/paho.mqtt.c running:
```bash
$ cd paho.mqtt.c
$ git checkout v1.3.8
$ cmake -Bbuild -H. \
-DPAHO_ENABLE_TESTING=OFF \
-DPAHO_BUILD_STATIC=ON \
-DPAHO_WITH_SSL=OFF \
-DPAHO_HIGH_PERFORMANCE=ON \
-DCMAKE_INSTALL_PREFIX=$HOME/fibocom/openlinux/marthe_linux/lib/mqtt/paho_c \
-DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain-arm-linux-gnueabi.cmake
$ sudo cmake --build build/ --target install
```
The `toolchain-arm-linux-gnueabi.cmake` file that I'm using is [this file](https://gist.github.com/LOCNNIL/658e891c8b96ae0fd9a8a1c0f34f3077)
Then, looks like it configure, compiles and installed successfully.
The configuration:

Compilation and installation:

The installed folders:

Then in the paho.mqtt.cpp lib installation:
```bash
$ cd ~/My_project_root/lib/paho.mqtt.cpp
$ git checkout master
$ cmake -Bbuild -H. \
-DPAHO_BUILD_SHARED=FALSE \
-DPAHO_WITH_SSL=FALSE \
-DPAHO_BUILD_DOCUMENTATION=OFF \
-DPAHO_BUILD_SAMPLES=ON \
-DPAHO_BUILD_STATIC=ON \
-DCMAKE_PREFIX_PATH=$HOME/fibocom/openlinux/marthe_linux/lib/mqtt/paho_c \
-DCMAKE_INSTALL_PREFIX=$HOME/fibocom/openlinux/marthe_linux/lib/mqtt/paho_cpp \
-DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain-arm-linux-gnueabi.cmake
```
I got the followed output:
```bash
-- The CXX compiler identification is GNU 9.4.0
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabi-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find PahoMqttC (missing: PAHO_MQTT_C_LIBRARIES
PAHO_MQTT_C_INCLUDE_DIRS)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
cmake/FindPahoMqttC.cmake:33 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
src/CMakeLists.txt:26 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/lincoln/fibocom/openlinux/marthe_linux/lib/paho.mqtt.cpp/build/CMakeFiles/CMakeOutput.log".
```
My output log:
[CMakeOutput.log](https://github.com/eclipse/paho.mqtt.cpp/files/9820629/CMakeOutput.log)
I don't understand why this is getting an error, the path to paho C already has
been specified
Information about my system:
`Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux`
Contributor guide
Research direction
Start with cmake/FindPahoMqttC.cmake and src/CMakeLists.txt, then review the supplied toolchain-arm-linux-gnueabi.cmake file and the Paho C install prefix. Re-run the CMake configure step with the shown cross-compilation options and inspect whether the installed Paho C library and include paths are discoverable. Done means configuration completes and the Paho C++ build can proceed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100