Important: Please read the Qt Code of Conduct -

Can not call application function from shared library. Unresolved symbol error

  • Hi all.

    I am trying to make a shared library, some sort of plugin, and I want this library to call some functions from my main app.
    Library code is (simplified):

    #include "../../core/plugin.h"
    #include "iostream"
    #include "objmeshloader.h"
    static void register_plugin(zim::AppContainer *container)
        std::cout << "Registering plugin objloader for app version: " << container->getAppMajorVersion() << std::endl;

    When I try to load it using QLibrary it gives me error:

    Error: Cannot load library undefined symbol: _ZN3zim12AppContainer13getMeshLoaderEv

        QLibrary lib(filePath);
        if (!lib.load()) {
            qFatal("Unable to load plugin %s. Error: %s", qUtf8Printable(filePath), qUtf8Printable(lib.errorString()));

    When I dump symbols it seems that everything is OK

    nm -g  app | grep _ZN3zim12AppContainer13getMeshLoaderEv
    000000000000738a T _ZN3zim12AppContainer13getMeshLoaderEv
    nm -g  plugins/ | grep _ZN3zim12AppContainer13getMeshLoaderEv
    U _ZN3zim12AppContainer13getMeshLoaderEv

    Why it can not link library?

  • So I solved thi issue.

    QMAKE_LFLAGS += -export-dynamic

  • Moderators

    @zim32 said in Can not call application function from shared library. Unresolved symbol error:

    That's your whole file path? Is the working dir the same as location of that library, then?

  • Library is located under ./plugins/ directory of my app. It works fine (because I was able to load library before calling container->getMeshLoader() function)

  • It seems I can't call any function defined if my main app.

    F.e. if I declare some simple function in plugin.h file

    extern "C" {
    void some_test_func();

    and then define it in my main.cpp

    void some_test_func() {
        qDebug("some_test_func called");

    Trying to call it from shared library gives me undefined symbol: some_test_func

  • So I solved thi issue.

    QMAKE_LFLAGS += -export-dynamic

Log in to reply