Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Getting LNK2019 error on plugin compilation

Getting LNK2019 error on plugin compilation

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
20 Posts 4 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D deleted456
    24 Jan 2019, 13:45

    Hello as a newbie to qt, today i tried to create a plugin (.dll file) by following the tutorial on https://www.qcad.org/en/tutorial-creating-a-qcad-plugin
    Im using qt creator 3.5.1 Based on Qt 5.5.1 (MSVC 2013, 32 bit) as recommended in https://www.qcad.org/en/qcad-documentation/supported-platforms
    However when i try to build the project i get the following error messages, (first picture)

    0_1548337509021_1.png

    RExamplePlugin.obj: -1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl RPluginInfo::RPluginInfo(void)" (_imp??0RPluginInfo@@QEAA@XZ) referenced in function "public: virtual class RPluginInfo __cdecl RExamplePlugin::getPluginInfo(void)" (?getPluginInfo@RExamplePlugin@@UEAA?AVRPluginInfo@@XZ)

    RExamplePlugin.obj: -1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl RPluginInfo::set(class QString const &,class QVariant const &)" (_imp?set@RPluginInfo@@QEAAXAEBVQString@@AEBVQVariant@@@Z) referenced in function "public: virtual class RPluginInfo __cdecl RExamplePlugin::getPluginInfo(void)" (?getPluginInfo@RExamplePlugin@@UEAA?AVRPluginInfo@@XZ)

    RExamplePlugin.obj: -1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl RPluginInfo::~RPluginInfo(void)" (_imp??1RPluginInfo@@QEAA@XZ) referenced in function "int public: virtual class RPluginInfo __cdecl RExamplePlugin::getPluginInfo(void)'::1'::dtor$0" (?dtor$0@?0??getPluginInfo@RExamplePlugin@@UEAA?AVRPluginInfo@@XZ@4HA)

    On the issues screen it says RExamplePlugin.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl RPluginInfo::~RPluginInfo(void)" ..

    My files are,

    exampleplugin.pro
    CONFIG += plugin
    TARGET = example
    include(C:/qcad-master/shared.pri)

    HEADERS = RExamplePlugin.h
    SOURCES = RExamplePlugin.cpp
    TEMPLATE = lib

    DESTDIR = ../../../plugins
    LIBS += C:/qcad-master/qcadcore.lib
    LIBS += C:/qcad-master/qcadgui.lib
    LIBS += C:/qcad-master/qcadecmaapi.lib

    RExamplePlugin.h
    #include <QObject>
    #include <QScriptEngine>

    #include "C:/qcad-master/src/core/RPluginInterface.h"
    class RExamplePlugin : public QObject, public RPluginInterface
    {
    Q_OBJECT
    Q_INTERFACES(RPluginInterface)

    public:
    virtual bool init() { return true; }
    virtual void uninit(bool) {}
    virtual void postInit(InitStatus) {}
    virtual void initScriptExtensions(QScriptEngine) {}
    virtual RPluginInfo getPluginInfo();
    virtual bool checkLicense() { return true; }
    };

    RExamplePlugin.cpp

    #include "RExamplePlugin.h"

    RPluginInfo RExamplePlugin::getPluginInfo() {
    RPluginInfo ret;
    ret.set("Version", "1.0");
    ret.set("ID", "EXAMPLE");
    ret.set("Name", "Example Plugin");
    ret.set("License", "GPLv3");
    ret.set("URL", "http://qcad.org");
    return ret;
    }

    #if QT_VERSION < 0x050000
    QT_BEGIN_NAMESPACE
    Q_EXPORT_PLUGIN2(example, RExamplePlugin)
    QT_END_NAMESPACE
    #endif

    when i delete the below lines of code from RExamplePlugin.cpp files, the build works without any error but then in QCAD (a qt based cad software) the plugin id,name,version are all unknown. And i got plugin verification error. (as shown in the second picture)

    0_1548337525912_2.png

    Can someone try to follow those tutorial steps and verify that he can build the .dll file? or let me know about the source of my error
    Thanks a lot

    A Offline
    A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on 24 Jan 2019, 18:42 last edited by
    #2

    Hi @wodasdsa which compiler are you using? you need exactly the same that was use to build QCad.

    And it does not matter which Qt version was used to build Qt Creator, what matters is the Qt version and compiler you use to build the plugin. That can be totally different things ( or even the same)

    Regards

    Qt has to stay free or it will die.

    1 Reply Last reply
    3
    • D Offline
      D Offline
      deleted456
      wrote on 25 Jan 2019, 11:54 last edited by
      #3

      Hello @aha_1980 thanks a lot for your quick reply,
      As you mentioned i checked again my compilers and saw that i used Microsoft Visual C++ Compiler (MSVC) 12.0 (2013) as decleared in https://www.qcad.org/en/qcad-documentation/supported-platforms. You can see the compilers used in the picture.
      0_1548417141378_3.png
      my compiler
      0_1548417239306_4.png
      compiler used to build Qcad

      So im not sure if i got it correctly, did i used the same compiler with the one used to build QCad?

      Thanks a lot.

      A 1 Reply Last reply 25 Jan 2019, 12:13
      0
      • D deleted456
        25 Jan 2019, 11:54

        Hello @aha_1980 thanks a lot for your quick reply,
        As you mentioned i checked again my compilers and saw that i used Microsoft Visual C++ Compiler (MSVC) 12.0 (2013) as decleared in https://www.qcad.org/en/qcad-documentation/supported-platforms. You can see the compilers used in the picture.
        0_1548417141378_3.png
        my compiler
        0_1548417239306_4.png
        compiler used to build Qcad

        So im not sure if i got it correctly, did i used the same compiler with the one used to build QCad?

        Thanks a lot.

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 25 Jan 2019, 12:13 last edited by
        #4

        @wodasdsa So QCAD is build as 64bit version, so you need to build your plugin as 64 bit too.

        You'll need MSVC2013 64 bit (which you seem to have, the x86_amd64 version) and a suitable Qt version (can't tell that due to missing screenshot).

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • D Offline
          D Offline
          deleted456
          wrote on 27 Jan 2019, 13:04 last edited by
          #5

          Greetings,
          I just uninstalled qt and compiler then installed it from https://download.qt.io/archive/qt/5.5/5.5.1/
          I tried installing "qt-opensource-windows-x86-msvc2013_64-5.5.1.exe" and while installing i selected msvc2013_64 bit and installed Qt5.5 and msvc2013. On the kits panel i can see that Mscv2013_64 bit is installed but compiler shows 32bit version.

          2_1548593731602_7.png 1_1548593731602_6.png 0_1548593731601_5.png

          While building the plugin, I still get the error message i got in the previous version. And i'm not sure the issue is based on using different bit versions. There is no 64bit qt installer on https://download.qt.io/archive/qt/5.5/5.5.1/ and i can see that qt is compiled with
          Architecture: x86_64 (the last pic from my previous post).

          Could you please try to build the plugin by using your own qt and compiler and let me know about the specs? Cause im pretty sure that i installed the 64bit version of msvc2013 and respective sdk.

          Apologies for taking your time and thanks a lot.

          A 1 Reply Last reply 27 Jan 2019, 13:15
          0
          • D deleted456
            27 Jan 2019, 13:04

            Greetings,
            I just uninstalled qt and compiler then installed it from https://download.qt.io/archive/qt/5.5/5.5.1/
            I tried installing "qt-opensource-windows-x86-msvc2013_64-5.5.1.exe" and while installing i selected msvc2013_64 bit and installed Qt5.5 and msvc2013. On the kits panel i can see that Mscv2013_64 bit is installed but compiler shows 32bit version.

            2_1548593731602_7.png 1_1548593731602_6.png 0_1548593731601_5.png

            While building the plugin, I still get the error message i got in the previous version. And i'm not sure the issue is based on using different bit versions. There is no 64bit qt installer on https://download.qt.io/archive/qt/5.5/5.5.1/ and i can see that qt is compiled with
            Architecture: x86_64 (the last pic from my previous post).

            Could you please try to build the plugin by using your own qt and compiler and let me know about the specs? Cause im pretty sure that i installed the 64bit version of msvc2013 and respective sdk.

            Apologies for taking your time and thanks a lot.

            A Offline
            A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on 27 Jan 2019, 13:15 last edited by
            #6

            @wodasdsa

            Please show screenshots of you Kits (click on Desktop 5.5.1 ... resp. Desktop (default)) to see how the Kits are set up.

            Could you please try to build the plugin by using your own qt and compiler

            Unfortunately, no. I neither have Windows nor MSVC :)

            Qt has to stay free or it will die.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              deleted456
              wrote on 27 Jan 2019, 13:34 last edited by
              #7

              Here you can see the information about kits,
              0_1548595843415_3.png

              Do you think these errors are based on using different bit versions? (btw i dont get the error and compile succesfully if i erase getPluginInfo() method from Reaxmpleplugin.cpp file (as i explained in my very first post)

              0_1548595903865_3.png

              Unfortunately, no. I neither have Windows nor MSVC :)

              Oh okey thanks a lot anyways..

              1 Reply Last reply
              0
              • D Offline
                D Offline
                deleted456
                wrote on 27 Jan 2019, 13:44 last edited by
                #8

                and the manual desktop (default) panel,

                0_1548596188432_4.png

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  deleted456
                  wrote on 28 Jan 2019, 15:41 last edited by
                  #9

                  any update?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 28 Jan 2019, 21:28 last edited by
                    #10

                    Hi,

                    From the looks of it, you don't export any symbol from your library. This means that, on Windows, the linker won't find them.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • D Offline
                      D Offline
                      deleted456
                      wrote on 28 Jan 2019, 22:13 last edited by deleted456
                      #11

                      @SGaist said in Getting LNK2019 error on plugin compilation:

                      This means that, on Windows, the linker won't find them.

                      Hello thanks for you answer, to be honest im quite newbie to qt and im not exactly got what you have suggested. You mean the compiler doesnt found qcadcore.lib,qcadgui.lib and qcadecmaapi.lib files in exampleplugin.pro file? And if so how can i solve it?
                      Thanks a lot for your help

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 28 Jan 2019, 22:31 last edited by SGaist
                        #12

                        Did yes, they want to see on them.

                        It's rather that they are not generated because no symbol were exported.

                        [edit: Something went wrong with the answer SGaist]

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          deleted456
                          wrote on 28 Jan 2019, 22:40 last edited by
                          #13

                          Sorry what do you mean?

                          I had .dll files from source code and used this method https://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/ to create .lib files

                          J 1 Reply Last reply 29 Jan 2019, 06:10
                          0
                          • D deleted456
                            28 Jan 2019, 22:40

                            Sorry what do you mean?

                            I had .dll files from source code and used this method https://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/ to create .lib files

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 29 Jan 2019, 06:10 last edited by
                            #14

                            @wodasdsa You should read http://doc.qt.io/qt-5/sharedlibrary.html

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1
                            • D Offline
                              D Offline
                              deleted456
                              wrote on 30 Jan 2019, 14:54 last edited by
                              #15

                              i dont think the problem is in libraries i cant compile without them either..

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 30 Jan 2019, 20:57 last edited by
                                #16

                                Can you show the relevant header(s) content ?

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  deleted456
                                  wrote on 1 Feb 2019, 11:09 last edited by
                                  #17

                                  Sure,1_1549019333195_02.png 0_1549019333194_01.png
                                  to see shared.pri you can check the following link,
                                  https://github.com/qcad/qcad/blob/master/shared.pri

                                  Thanks

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 1 Feb 2019, 20:53 last edited by
                                    #18

                                    You're on Windows and not exporting any symbol hence the problem. Do as @jsulm suggested and use the export macros.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    1
                                    • D Offline
                                      D Offline
                                      deleted456
                                      wrote on 3 Feb 2019, 00:20 last edited by
                                      #19

                                      How can i do that? im newbie to qt and didnt understand most the terms used in that documentation..

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on 3 Feb 2019, 17:46 last edited by
                                        #20

                                        Just follow the indications in the "Using Symbols from Shared Libraries" part.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        1

                                        11/20

                                        28 Jan 2019, 22:13

                                        • Login

                                        • Login or register to search.
                                        11 out of 20
                                        • First post
                                          11/20
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • Users
                                        • Groups
                                        • Search
                                        • Get Qt Extensions
                                        • Unsolved