Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo SDK Support › Issue with Running Application with Custom C++ Code

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25328

    Filmixyy

    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!

    #25329

    Filmixyy

    Now i;ve got the problem:

    C:\Users\veltr\Desktop\UserLoginApiTest\CMakeLists.txt:9: błąd: By not providing “FindFelgoLive.cmake” in CMAKE_MODULE_PATH this project
    has asked CMake to find a package configuration file provided by
    “FelgoLive”, but CMake did not find one.

    Could not find a package configuration file provided by “FelgoLive” with
    any of the following names:

    FelgoLiveConfig.cmake
    felgolive-config.cmake

    Add the installation prefix of “FelgoLive” to CMAKE_PREFIX_PATH or set
    “FelgoLive_DIR” to a directory containing one of the above files. If
    “FelgoLive” provides a separate development package or SDK, be sure it has
    been installed.

    #25330

    Filmixyy

    After successfully running the application locally without encountering any issues, I’m now exploring the possibility of running the application with its native C++ code on Felgo DevApp. However, I’ve noticed that when attempting to do so, the functionality on the phone doesn’t seem to work as expected.

     

    If its not possible, do u know a way to test the whole app on ios phone directly (in a way that C++ native code works) ?

    #25332

    Günther
    Felgo Team

    Hi Filmixyy,

    C++ code requires compilation and can not be reloaded with Felgo Live at runtime. This means that the pre-built Desktop Live Client and Mobile Dev App can not use any custom C++ code of your project.

    However, you can still use Felgo Live by integrating the Felgo Live Module and compiling your project (which will then also include your custom C++ code). This is what the FelgoLiveClient code in the main.cpp is for. You can learn more here: https://felgo.com/doc/qml-hot-reload-felgo-live/#c-native-code-build-your-own-live-clients-with-the-felgo-live-module

    You can create both a Desktop and Mobile client this way. For compiling Felgo projects on mobile platforms, you can follow the steps in the deployment guide: https://felgo.com/doc/felgo-deployment-ios/#add-felgo-packages-for-ios-platform

    Best,
    Günther

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded