-
Notifications
You must be signed in to change notification settings - Fork 446
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
install the library to a non-standard location fails on find lib and undefined headers #427
Comments
Yes, this is the right place! I've been trying to get up to speed on CMake recently, as the build system was implemented by someone else who wandered off a while back. But I'm starting to get the hang of it now, and will see if I can help figure this out. |
+1 for updates to cmake, @SaKa1979 I agree the exported targets are not of much help. |
I have opted to use the c api directly instead, it works out of the box with cmake. |
@SaKa1979 I revisited the cmake build for paho.mqtt.cpp and it turns out it is was easier than I thought. So in your case, remove all find_library, find_path and target_include_directories calls, anything that you added in your issue description. All you need is roughly this: find_package(PahoMqttCpp REQUIRED)
add_executable(myapp ${MYSOURCES})
target_link_libraries(myapp PahoMqttCpp::paho-mqttpp3) Also you have to set your CMAKE_PREFIX_PATH so that both import targets can be found, paho.mqtt.cpp as well as paho.mqtt.c:
|
I got the final clue from this Stackoverflow post, even though the naming of the targets provided in the answer are wrong. But the general idea was correct: |
Thank you very much! |
How did it go? What was your solution? |
I'm building Paho_cpp as part of a project (Linux). The paho_cpp repository (commit #2ff3d155dcd10564f1816675789284b4efd79eb7) is added as a submodule. The paho_c repository (commit #f7799da95e347bbc930b201b52a1173ebbad45a7) is added as a submodule of paho_cpp.
The /usr/local/lib does not contain any paho libraries.
To build the libraries and install them in a non-standard location I use the following:
C library:
CPP library:
Without changing anything to the paho_cpp files, find_package(PahoMqttC REQUIRED) fails. So I added the specific paths to the FindPahoMqttC.cmake like so:
In my own project I've added a FindPahoMqttCpp.cmake file to find PahoMqttCpp. This works, the lib is found.
The project's CMakeList contains:
Building results in
/usr/bin/ld: cannot find -lpaho-mqttpp3: No such file or directory
. So, it's apparently unable to find the library.I also need to explicitly target the _install/include directory so the mqtt/async_client.h file is located.
First I don't understand why it will not build out-of-the box when using a non-standard installation directory.
Second, why the linker error when the libraries are found by the build system?
Third, Why is necessary to explicitly target the include directory?
I hope I'm in the right place to post these questions and I especially hope somebody can help me out here. I've been struggling with this for multiple days now. Thanks in advance.
The text was updated successfully, but these errors were encountered: