eclipse-paho / eclipse-paho/paho.mqtt.cpp

Cross compiling error: "Could NOT find PahoMqttC (missing: PAHO_MQTT_C_LIBRARIES PAHO_MQTT_C_INCLUDE_DIRS)"

Open
#412 6 comments 2 reactions 0 assignees View on GitHub
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:

![configured-paho-mqtt-c](https://dsm01pap001files.storage.live.com/y4mUgE7VNXJtpX89VaqRxayKNe1t1HNq7w5c409UDYqu5tlYcTUYaG-QiPZ-f7FnAEYngf2AJttIN1FHZcVVZWJE1T794boapB10VuQVQ5Lxmb_M601XXdbX4rOPuKDQP_U7ypWwHTmS_yt36MgVfFpLnAL36yIgNh2ab69FwQ6GB853IcSiwh-jHC1-NkG1sf5?width=736&height=378&cropmode=none)

Compilation and installation:

![builded-paho-mqtt-c](https://dsm01pap001files.storage.live.com/y4mwBgg3Yp9v1gTJ8zh0DNw1wBUSwvxvKc6YWZs1wI-8U6u71SOziGZHAccARcMXPi-XgTdq4uXzxdMQaEnqslS0H57DoH6gcaJ3ENcy-5l7WrjnpVsPbBvgRvJEnbeuo7LSNm1qAC94118gxmfqGdlj3vV5uuE8yf5KtFDzdYqBkSkkmlNQWlu86CYB0QQWwHY?width=581&height=257&cropmode=none)

The installed folders:

![installed-paho-mqtt-c](https://dsm01pap001files.storage.live.com/y4mynfy4Wl7q1kC7Qsl0PJct0CjnwCuZvoZcIkWHPx5CxDc6ub_13tbmY2Kl8G4b4wYq3ee9oQ7rO8R2BTCfn416k1iG_7lc_6gb6AYsCqCXzHEI7N99aFeKh1HLgqJ6YLtwTuLDoURrFI_-1RP45Wqib8WW7RPpD2mFZCLMgbmwsETFp6tjgf3fU3JgipEiZd2?width=280&height=157&cropmode=none)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.