Nominate our 2022 Qt Champions!

Building with a static map tiles plugin in QML (Qt Mobility)

  • Hi

    I have created a custom map tiles engine in C++, which works well when compiled as a dynamic library and imported into a QML app on the simulator.

    I wish however to have it as a static library, and bundle it in with my app... I can't get this to work.

    My plugin's .pro file has the following lines
    TARGET = MyMaps
    CONFIG += staticlib mobility
    MOBILITY += location

    I also have the following line in one of the .cpp files:
    @Q_EXPORT_PLUGIN2(MyMaps, QMyMappingProvider)@

    Building this seems to work OK, a libMyMaps.a file is produced.

    However I am having difficulty using it in my QML app.

    My QML app's .pro file has the following lines
    @LIBS += \QtWorkspace\MyMaps-build-simulator\debug\libMyMaps.a@

    It builds OK, but when I run it, it crashes when loading my QML file. It contains the following:
    Map {
    plugin: Plugin {
    name: "mymaps"

    I have tried including the line
    in my application's main.cpp, however this will not build, I get the error:
    @undefined reference to `qt_plugin_instance_MyMaps()'@

    Again, the plugin works well when included as a dynamic library!

    How can I bundle this static library with my app? Must I have it as a separate plugin? It would be much cleaner for me to have it all as one project.

    Help appreciated.

Log in to reply