Getting error on plugin tutorial

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
woddy
Junior Member
Posts: 13
Joined: Mon Mar 05, 2018 10:44 pm

Getting error on plugin tutorial

Post by woddy » Wed Nov 21, 2018 8:15 pm

Hello again and apologies for asking another newbie question.
While i was practising on tutorials i did come across creating a Qcad Plugin one. I downloaded the source code exampleplugin.pro file (the one having RESOURCES = scripts.qrc) and then debug it in Qt Creator 4.7.2 Once i debugged it i got cannot find -lqcadcore , -lqcadgui, -lqcadecmaapi and id returned 1 exit status. On compile output i get,
C:/Qt/Tools/mingw730_64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lqcadcore
C:/Qt/Tools/mingw730_64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lqcadgui
C:/Qt/Tools/mingw730_64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lqcadecmaapi
collect2.exe: error: ld returned 1 exit status
Error while building/deploying project exampleplugin (kit: Desktop Qt 5.12.0 MinGW 64 bit)
When executing step "Make"
Is it because of using Qt 5.11.2 and 5.5.1 on Qcad? or i forgot to add some files?
Thanks a lot and sorry again about my basic question.
Attachments
1.png
1.png (96.55 KiB) Viewed 5732 times

woddy
Junior Member
Posts: 13
Joined: Mon Mar 05, 2018 10:44 pm

Re: Getting error on plugin tutorial

Post by woddy » Thu Nov 22, 2018 1:40 pm

Should i use

Code: Select all

LIBS +=  -L"C:/qcad-master" -lqcadcore
LIBS +=  -L"C:/qcad-master" -lqcadgui
LIBS +=  -L"C:/qcad-master" -lqcadecmaapi
instead of

Code: Select all

LIBS += -lqcadcore -lqcadgui -lqcadecmaapi
once i do that i got file format not recognized error. Do i need qcadcore.lib, qcadgui.lib and qcadecmaapi.lib files to compile it? If so where can i get them
Thanks

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Getting error on plugin tutorial

Post by andrew » Thu Nov 22, 2018 9:33 pm

Yes, you definitely need to add the path to the libraries (-L).

If you are compiling a plugin for a QCAD binary downloaded from qcad.org, you'd have to use the same Qt version and very likely also the same C++ compiler as we use for QCAD to make it work. You should see this information in the about dialog of QCAD. If you are compiling your own QCAD binary, any compiler should work, though we've only used MSVC under Windows so far..

Unfortunately, compiling a QCAD / Qt Plugin for an existing QCAD binary is not straightforward and might take a lot of trial and error to make it work. Using the same Qt version and compiler would be a start. I'd also drop linking in the QCAD libraries at first, until you can get the most basic plugin to load. You can see if the plugin is loaded (or why it is not) in the about dialog.

Note that you can extend and adjust most aspects of QCAD through its powerful and complete script interface without creating a C++ plugin, using a compiler or linking anything.

woddy
Junior Member
Posts: 13
Joined: Mon Mar 05, 2018 10:44 pm

Re: Getting error on plugin tutorial

Post by woddy » Fri Nov 23, 2018 5:22 pm

Hello Andrew,
Thanks a lot for your answer and helpful approach. Do you mind sharing or letting me know the directory of qcadcore.lib, qcadgui.lib and qcadecmaapi.lib files? Im just trying to learn qcad more by following tutorials.
Thanks again

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Getting error on plugin tutorial

Post by andrew » Mon Nov 26, 2018 11:21 am

You should be able to create the lib files from the dll (see Google or for example https://stackoverflow.com/questions/317 ... t-lib-file)

woddy
Junior Member
Posts: 13
Joined: Mon Mar 05, 2018 10:44 pm

Re: Getting error on plugin tutorial

Post by woddy » Tue Dec 25, 2018 1:26 pm

Greetings again,
By following https://adrianhenke.wordpress.com/2008/ ... -from-dll/ this website i managed to create first def then lib files for qcadcore,gui and ecmaapi. (I tried to add them on attachment but seems like their file type is not supported)
Then i tried to compile example.pro on https://qcad.org/en/tutorial-creating-a-qcad-plugin again by using qt5.5.1, msvc 2013 on windows 8.1 and although this time i didnt get any error related with the no libraries found, i got LNK2019: unresolved external symbol error.

Errors are,
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 dex file i deleted everything beside names and add Exports to convert it to .lib. Like,
EXPORTS
??0?$RResourceList@VRFont@@@@QAE@ABV0@@Z
??0?$RResourceList@VRFont@@@@QAE@XZ
??0?$RResourceList@VRLinetypePattern@@@@QAE@ABV0@@Z
??0?$RResourceList@VRLinetypePattern@@@@QAE@XZ
??0?$RResourceList@VRPattern@@@@QAE@ABV0@@Z
??0?$RResourceList@VRPattern@@@@QAE@XZ
...
??0RPluginInfo@@QAE@ABV0@@Z
??0RPluginInfo@@QAE@XZ
...

Once i release the examplugin.pro, on the plugins folder in qcad-master i get exampleplugin.exp and exampleplugin.lib file but not the exampleplugin.dll so there is no example plugin occurs in qcad's help-about-plugins window.

Can anyone help me to show what causes the error? Thank you very much and sorry for taking your time.
Attachments
2.png
2.png (225 KiB) Viewed 5442 times

woddy
Junior Member
Posts: 13
Joined: Mon Mar 05, 2018 10:44 pm

Re: Getting error on plugin tutorial

Post by woddy » Wed Jan 23, 2019 10:41 pm

Hello again,
As i worked out the out the code and used different qt versions,minGW and MSCV i got different results. However in some cases i managed to get qcadexample.dll file i got,
Plugin verification data mismatch in '.../plugins/qcadexample.dll' error on QCAD's about dialog.
Also plugin name, version, id are all unknown in that panel. I know the problem occurs from the below code in RExamplePlugin.cpp file,

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;
}

but i dont know why i can compile the files when i draw the above line in my code and why i cannot when i add them. I still got,

RExamplePlugin.obj : 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 : 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 : 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)
..\..\..\plugins\qcadexample.dll : fatal error LNK1120: 3 unresolved externals.

error. I wonder can someone verify that he can compile exampleplugin.pro file in support/examples/exampleplugin on windows by using qt creator 3.5.1 based on Qt 5.5.1 (MSVC 2013, 32 bit)? Im not sure if im skipping something or there is something wrong in the code? Im sorry for bothering you with my neewbie questions.

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


Thank you.

Post Reply

Return to “QCAD 'How Do I' Questions”