Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.
This repository was archived by the owner on Nov 29, 2022. It is now read-only.

Can not link libaho-mqtt3cs.so in my project #10

@WangFengtu1996

Description

@WangFengtu1996

HI,all

  • Thanks for your project providing a effective way to link the paho.mqtt.c in my project with cmake.
  • But when I use it in my project, I got the error in link step /usr/bin/ld: 找不到 -lpaho-mqtt3cs. I would appreciate it if you could give me some guidance

detail information

  • pahomqtt.cmake
include(ExternalProject)
find_package(Git REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(OPENSSL REQUIRED openssl)

ExternalProject_add(
    pahomqtt
    GIT_REPOSITORY "https://github.com/eclipse/paho.mqtt.c.git"
    GIT_TAG "master"
    UPDATE_COMMAND ""
    PATCH_COMMAND ""
    SOURCE_DIR "${CMAKE_BINARY_DIR}/paho-src"
    CMAKE_ARGS -DPAHO_WITH_SSL=TRUE -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/paho-build
)

include_directories(${CMAKE_BINARY_DIR}/paho-build/include)
link_directories(${CMAKE_BINARY_DIR}/paho-build/lib)
  • project CMakeLists.txt
include(pahomqtt)
add_dependencies(connect pahomqtt)
target_link_libraries(connect PUBLIC paho-mqtt3cs)  # connect is a dynamic library name compiled

env

  • ubuntu 18.04
  • cmake version 3.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions