我对CMake
. 所以这可能是一个菜鸟问题..
我正在尝试使用CMake
. 我希望我的程序发布到 mqtt 代理。我在 Linux 上运行。
所以我https://github.com/eclipse/paho.mqtt.cpp
通过做(并排)安装了相应的c项目
$ git clone https://github.com/eclipse/paho.mqtt.c.git
$ cd paho.mqtt.c
$ git checkout v1.3.1
$ cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_ENABLE_TESTING=OFF
$ sudo cmake --build build/ --target install
$ sudo ldconfig
根据文档,然后做。
$ git clone https://github.com/eclipse/paho.mqtt.cpp
$ mkdir build
$ cd build
$ cmake ../
$ make
$ sudo make install
这一切都很好,没有任何错误。现在我在我自己的项目中我自己的 cmakelists 文件中放入了什么,我可以使用这些库?所以我可以做到。
#include "mqtt/async_client.h"
int main(int argc, char *argv[]){
std::cout << "Hello World!" << std::endl;
mqtt::async_client cli(DFLT_ADDRESS, "", 120, PERSIST_DIR);
return 0;
}
我尝试了一个简单的。
cmake_minimum_required(VERSION 2.8.9)
project (hello)
find_package(PahoMqttCpp REQUIRED)
add_executable(hello helloworld.cpp)
target_link_libraries(hello ${PAHO_CPP_LIB})
但这似乎还不够……我明白了
helloworld.cpp:(.text+0xd3): undefined reference to `mqtt::async_client::~async_client()'
任何帮助,将不胜感激。