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.cpp\paho.mqtt.c\src
下的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-mqt