Important: Please read the Qt Code of Conduct -

[SOLVED] Can't link static library to executable - missing declarations?

  • Here I am, again. This is output from Output panel (Compiling EXE with Project.Global.lib (static library)).
    Project.Global.lib(SingleCoreApplication.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QLocalServer::listen(class QString const &)" (_imp?listen@QLocalServer@@QAE_NABVQString@@@Z) referenced in function "protected: void __thiscall Project::Global::SingleCoreApplication::init(void)" (?init@SingleCoreApplication@Global@Project@@IAEXXZ)

    Something is's not available to linker, but what? I think it's missing Qt Classes, but I am not sure...

  • Do you want to link statically against the Qt library? Did you build a static version of the Qt library? Do you actually use the static build (you linker is obviously looking for an imported symbol from a shared library)?

  • No. I am building application, which takes global static library Project.Global.lib, which includes classes SingleCoreApplication (SingleApplication). No, I didn't build static Qt libraries (Do I need it build?)

  • No you don't. Did you build the static lib against the same version of Qt?

  • Yes, I do it on one place.

  • Just to be sure: have you added the network module to your .pro file?

  • To Library or Application? To library yes, to application not.

    DONE. It works, but. It don't show any console window (application is running)...

  • Check if you are missing a CONFIG += console in your .pro and if the subsystem type is Console (/SUBSYSTEM:CONSOLE) if you are using MSVS.

Log in to reply