I have a problem with the async-client function. At compiled time the Qt creator console says that the function has been deleted.
moc_displaywindow.cpp: In static member function ‘static void DisplayWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)’:
moc_displaywindow.cpp:109:143: error: use of deleted function ‘Publisher::Publisher(const Publisher&)’
case 0: _t->commande((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< Publisher(*)>(_a[3]))); break;
^
In file included from displaywindow.h:8,
from moc_displaywindow.cpp:9:
minipub.h:68:7: note: ‘Publisher::Publisher(const Publisher&)’ is implicitly deleted because the default definition would be ill-formed:
class Publisher
^~~~~~~~~
minipub.h:68:7: error: use of deleted function ‘mqtt::async_client::async_client(const mqtt::async_client&)’
In file included from minipub.h:11,
from displaywindow.h:8,
from moc_displaywindow.cpp:9:
/usr/local/include/mqtt/async_client.h:153:2: note: declared here
async_client(const async_client&) =delete;
^~~~~~~~~~~~
In file included from moc_displaywindow.cpp:9:
displaywindow.h:26:10: note: initializing argument 3 of ‘void DisplayWindow::commande(int, int, Publisher)’
void commande(int number, int order, Publisher pub);
^~~~~~~~
moc_displaywindow.cpp:110:227: error: use of deleted function ‘Publisher::Publisher(const Publisher&)’
case 1: _t->switchImages((*reinterpret_cast< QPixmap(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< Publisher(*)>(_a[4])),(*reinterpret_cast< QLabel*(*)>(_a[5]))); break;
^
In file included from moc_displaywindow.cpp:9:
displaywindow.h:27:10: note: initializing argument 4 of ‘void DisplayWindow::switchImages(QPixmap, int, int, Publisher, QLabel*)’
void switchImages(QPixmap display,int number, int order, Publisher pub, QLabel *label);
^~~~~~~~~~~~
make: *** [Makefile:512: moc_displaywindow.o] Error 1
16:04:52: Le processus "/usr/bin/make" s'est terminé avec le code 2.
Erreur lors de la compilation/déploiement du projet IHM_ASTREOS_REPL_ETH_SOL (kit : Desktop)
When executing step "Make"
I don't understand why. I have used it on another code with work.
Some research indicates that it's a constructor error. But i don't know what to do.
minipub.h :
class Publisher
{
public:
Publisher(const std::string &server);
~Publisher(){}
void publish(const std::string &topic, const void *payload, size_t size, int qos);
private:
mqtt::async_client client;
};
minipub.cpp :
Publisher::Publisher(const string &server) : client(server, CLIENT_ID, PERSIST_DIR){
callback cb; //This does not stay accessible in memory ?!
client.set_callback(cb);
string timeLWT = TimeCode();
// verifying the presence of the key and certificates.
std::ifstream tstore(TRUST_STORE);
if (!tstore) {
std::cerr << "The trust store file does not exist: " << TRUST_STORE << endl;
}
std::ifstream kstore(KEY_STORE);
if (!kstore) {
std::cerr << "The key store file does not exist: " << KEY_STORE << endl;
}
string LWTAndTime = ID_CARD + ";" + "LWT" + ";" + timeLWT + ";" + ID_CARD;
auto sslopts = mqtt::ssl_options_builder()
.trust_store(TRUST_STORE)
.key_store(KEY_STORE)
.error_handler([](const std::string& msg) {
std::cerr << "SSL Error: " << msg << std::endl;
})
.finalize();
auto willmsg = mqtt::message(LWT_TOPIC,LWTAndTime,QOS,false);
auto connOpts = mqtt::connect_options_builder()
.clean_session()
.will(std::move(willmsg))
.ssl(std::move(sslopts))
.finalize();
try {
cout << "\nConnecting..." << endl;
mqtt::token_ptr conntok = client.connect(connOpts);
cout << "Waiting for the connection..." << endl;
conntok->wait();
cout << " ...OK" << endl;
}
catch (const mqtt::exception& exc) {
cerr << exc.what() << endl;
}
}
I tried copy past from another program that is working (on another device) same problem.