Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
locnnil opened this issue Oct 19, 2022 · 6 comments

Comments

@locnnil
Copy link

locnnil commented Oct 19, 2022

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 and also 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:

$ mkdir lib 
$ cd lib
$ git submodule add [email protected]:eclipse/paho.mqtt.cpp.git
$ git submodule add [email protected]: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:

$ 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

Then, looks like it configure, compiles and installed successfully.

The configuration:

configured-paho-mqtt-c

Compilation and installation:

builded-paho-mqtt-c

The installed folders:

installed-paho-mqtt-c

Then in the paho.mqtt.cpp lib installation:

$ 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:

-- 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

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

@rafalSFara
Copy link

I had similar problem and I was able to solve it by setting:

'CMAKE_FIND_ROOT_PATH_MODE_LIBRARY' = 'BOTH'
'CMAKE_FIND_ROOT_PATH_MODE_INCLUDE' = 'BOTH'

@locnnil
Copy link
Author

locnnil commented Nov 3, 2022

Interesting @rafalSFara did you set this using the command options when running cmake? Like:

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/PahoMqttC \
    -DCMAKE_INSTALL_PREFIX=$HOME/fibocom/openlinux/marthe_linux/lib/mqtt/PahoMqttCPP \
    -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain-arm-linux-gnueabi.cmake \
    -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
    -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH

I've try this way but still not working.

@rafalSFara
Copy link

Actually I've used it in the conan recipe, but your usage looks correct to me.
Maybe you should try with explicitly set CMAKE_FIND_ROOT_PATH to PahoMqttC then?

@locnnil
Copy link
Author

locnnil commented Nov 3, 2022

I'm trying to isolate my problem, so now I'm tryng to install both in a separed folder, but still not working. I can install paho.mqtt.c but when I try to install the C++ library It fails on Cmake configuration.

Following your tip, I tried:

cmake -Bbuild -H. \
    -DPAHO_BUILD_SHARED=FALSE \
    -DPAHO_WITH_SSL=FALSE \
    -DPAHO_BUILD_DOCUMENTATION=OFF \
    -DPAHO_BUILD_SAMPLES=ON \
    -DPAHO_BUILD_STATIC=ON \
    -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain-arm-linux-gnueabi.cmake \
    -DCMAKE_PREFIX_PATH=$HOME/projects/mqtt/lib \
    -DCMAKE_INSTALL_PREFIX=$HOME/projects/mqtt/lib \
    -DCMAKE_FIND_ROOT_PATH=$HOME/projects/mqtt/lib \
    -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
    -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH

But it still getting the same error.

@dovantuan02
Copy link

I'm trying to isolate my problem, so now I'm tryng to install both in a separed folder, but still not working. I can install paho.mqtt.c but when I try to install the C++ library It fails on Cmake configuration.

Following your tip, I tried:

cmake -Bbuild -H. \
    -DPAHO_BUILD_SHARED=FALSE \
    -DPAHO_WITH_SSL=FALSE \
    -DPAHO_BUILD_DOCUMENTATION=OFF \
    -DPAHO_BUILD_SAMPLES=ON \
    -DPAHO_BUILD_STATIC=ON \
    -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain-arm-linux-gnueabi.cmake \
    -DCMAKE_PREFIX_PATH=$HOME/projects/mqtt/lib \
    -DCMAKE_INSTALL_PREFIX=$HOME/projects/mqtt/lib \
    -DCMAKE_FIND_ROOT_PATH=$HOME/projects/mqtt/lib \
    -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
    -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH

But it still getting the same error.

hello guy. I have same problem. How do you fix it ?

@fpagliughi
Copy link
Contributor

fpagliughi commented Aug 7, 2024

@dovantuan02 Post the toolchain file that you're using and I will try to recreate the problem.
(toolchain-arm-linux-gnueabi.cmake)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants