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。

  • 相关阅读:
    Eclipse下Tomcat插件的安装
    支付宝接口资料解读
    文件转换器服务推荐
    接吻的学问
    Web小工具推荐
    两个优秀的免费字体资源
    每年考证时间
    Visual Studio 2008 简体中文版和MSDN下载
    生活小经验
    UIScrollView and lazy loading
  • 原文地址:https://www.cnblogs.com/studyforever/p/11737460.html
Copyright © 2011-2022 走看看