(Resolved)How can I use QtXml in my plugin?

For any question about plugins!
Post Reply
fblue
Posts: 37
Joined: Thu Oct 25, 2018 9:00 am

(Resolved)How can I use QtXml in my plugin?

Post by fblue »

Hello,
In my plugin CC, I want to use QtXml to load/save xml file to get/save parameters. But I got errors.
What should I do in my plugin source? Modify CMakeLists file of the plugin?

The compilation error as this:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QDomElement __cdecl QDomDocument::createElement(class QString const &)" (__imp_?createElement@QDomDocument@@QEAA?AVQDomElement@@AEBVQString@@@Z) referenced in function "public: void __cdecl qFilteringChainDlg::onFileSave(void)" (?onFileSave@qFilteringChainDlg@@QEAAXXZ) C:\Export\Users\CloudCompare\CloudCompare-2.10.2\build\plugins\3rdParty\qFilteringChain\qFilteringChainDlg.obj QFILTERING_CHAIN_PLUGIN

Thanks
Last edited by fblue on Wed Jul 03, 2019 8:33 am, edited 1 time in total.
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: How can I use QtXml in my plugin?

Post by daniel »

I believe the QtXml library has to be 'linked' in the CMake file of your plugin. See how this is done in the main project for instance (https://github.com/CloudCompare/CloudCo ... ts.txt#L65).

Oh and you'll also need to copy the corresponding DLL file next to CloudCompare's executable (this must also be done in some other plugins?)
Daniel, CloudCompare admin
fblue
Posts: 37
Joined: Thu Oct 25, 2018 9:00 am

(Resolved)Re: How can I use QtXml in my plugin?

Post by fblue »

Yes!
In my plugin CMakeLists file, I've added the following lines:
find_package(Qt5Xml REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL Qt5::Xml)

Then add the corresponding dlls in project and now the compilation is OK.

Ps:
I've tried many times in CMakeLists and finally the problem is because of the line find_package().
What I added was "find_package(QT5 COMPONENTS Xml REQUIRED)", and it didn't work. Frustrating!

Thanks a lot!
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: (Resolved)How can I use QtXml in my plugin?

Post by daniel »

Thanks for the feedback ;)
Daniel, CloudCompare admin
Post Reply