Hello everyone!
I’m having trouble running an application that contains custom C++ code. I’m following the documentation and examples, but I still encounter errors during compilation.
Here’s how my main.cpp
looks like:
#include "apimanager.h"
#include <QGuiApplication>
#include <QQmlContext>
#include <QQmlApplicationEngine>
#include <FelgoLiveClient>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
ApiManager apiManager;
engine.rootContext()->setContextProperty("apiManager", &apiManager);
const QUrl url(u"qrc:/UserLoginApiTest/main.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
FelgoLiveClient liveClient(&engine);
return app.exec();
}
Unfortunately, during compilation, I’m getting the following errors:
:-1: błąd: CMakeFiles/appUserLoginApiTest.dir/appUserLoginApiTest_autogen/mocs_compilation.cpp.obj: in function `QtPrivate::QMetaTypeForType<ApiManager>::getDefaultCtr()::{lambda(QtPrivate::QMetaTypeInterface const*, void*)#1}::operator()(QtPrivate::QMetaTypeInterface const*, void*) const’:
C:\Felgo\Felgo\mingw_64\include\QtCore\qmetatype.h:2299: błąd: undefined reference to `ApiManager::ApiManager(QObject*)’
:-1: Error: CMakeFiles/appUserLoginApiTest.dir/main.cpp.obj: in function `qMain(int, char**)’:
C:\Users\veltr\Desktop\UserLoginApiTest\main.cpp:15: błąd: undefined reference to `ApiManager::ApiManager(QObject*)’
I’ve just updated my CMakeLists.txt to include the necessary source files, but the problem persists. Additionally, I’ve included #include <FelgoLiveClient>
and created a FelgoLiveClient
object at the end of main.cpp
, as suggested by the documentation.
Has anyone encountered a similar issue? Or does anyone have any ideas on how to resolve it?
Thanks in advance for any help!