zoukankan      html  css  js  c++  java
  • Windows 编译 MQTT C

    如果遇到报错

    ADD_LIBRARY cannot create target "paho-mqtt3c" because another target with   the same name already exists.  The existing target is a shared library   created in source directory

    需要更改

    ..paho.mqtt.csrc

    下的CMakeLists.txt,将 -static后缀添加到文件中的静态库名称上,有两个地方需要进行此更改,在该文件中搜索PAHO_BUILD_STATIC

    第94行附近(添加-static到if语句中引用的库名称中):

    IF (PAHO_BUILD_STATIC)
        ADD_LIBRARY(paho-mqtt3c-static STATIC $<TARGET_OBJECTS:common_obj> MQTTClient.c)
        ADD_LIBRARY(paho-mqtt3a-static STATIC $<TARGET_OBJECTS:common_obj> MQTTAsync.c)

        TARGET_LINK_LIBRARIES(paho-mqtt3c-static ${LIBS_SYSTEM})
        TARGET_LINK_LIBRARIES(paho-mqtt3a-static ${LIBS_SYSTEM})

        INSTALL(TARGETS paho-mqtt3c-static paho-mqtt3a-static
        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
    ENDIF()

    第164行附近(添加-static到if语句中引用的库名称中):

    IF (PAHO_BUILD_STATIC)
        ADD_LIBRARY(paho-mqtt3cs-static STATIC $<TARGET_OBJECTS:common_ssl_obj> MQTTClient.c SSLSocket.c)
        ADD_LIBRARY(paho-mqtt3as-static STATIC $<TARGET_OBJECTS:common_ssl_obj> MQTTAsync.c SSLSocket.c)

        TARGET_LINK_LIBRARIES(paho-mqtt3cs-static ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
        TARGET_LINK_LIBRARIES(paho-mqtt3as-static ${OPENSSL_LIBRARIES} ${LIBS_SYSTEM})
        SET_TARGET_PROPERTIES(
            paho-mqtt3cs-static paho-mqtt3as-static PROPERTIES
            VERSION ${CLIENT_VERSION}
            SOVERSION ${PAHO_VERSION_MAJOR}
        COMPILE_DEFINITIONS "OPENSSL=1")

        INSTALL(TARGETS paho-mqtt3cs-static paho-mqtt3as-static
        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
    ENDIF()

    进行更改后,清除CMake缓存(或删除构建文件夹中的CMakeCache.txt文件)并重新运行CMake。

  • 相关阅读:
    如何正确设置数据库连接池的大小
    spring生命周期
    Spring高级进阶:BeanFactoryPostProcessor
    Spring Bean的生命周期(非常详细)
    表达式求值相关算法
    golang 命令行参数解析 hflag
    golang 标准命令行解析库 flag
    docker consul 环境搭建
    docker etcd 环境搭建
    mysql 事务
  • 原文地址:https://www.cnblogs.com/studyforever/p/11737460.html
Copyright © 2011-2022 走看看