#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");
}
我运行时,程序返回错误:
起初我以为问题出在mosquitto.h,我尝试了旧版本,但失败了。