MQTT Hello World C ++连接到代理

时间:2019-12-02 04:45:51

标签: c++ mqtt

#include <stdio.h>
#include <iostream>
#include <mosquitto.h>
#include <exception>
#include <stdlib.h>
#include "unistd.h"

using namespace std;

string hst = "***.***.***.***";
const char *host = hst.c_str();
int port = 1883;
string vhost = "***.***.***.***";
string usn = "****";
string vhusn = vhost + ":" + usn;
const char *username = vhusn.c_str();
string pwd = "****";
const char *password = pwd.c_str();
string tpc = "test";
const char *topic = tpc.c_str();

int main(int argc, char *argv[]) {

    int keepalive = 60;
    //cout << "here" << endl;
    bool clean_session = true;
    struct mosquitto *mosq = NULL;

    // create producer and connect to broker
    mosquitto_lib_init();

    cout << "here" << endl;
    system("pause");

}

我运行时,程序返回错误:

  • 找不到指定的文件

  • LNK2028和LNK2019

起初我以为问题出在mosquitto.h,我尝试了旧版本,但失败了。

0 个答案:

没有答案