Page 1 of 1

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

Posted: Tue Jul 02, 2019 3:46 pm
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

Re: How can I use QtXml in my plugin?

Posted: Tue Jul 02, 2019 8:17 pm
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?)

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

Posted: Wed Jul 03, 2019 8:16 am
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!

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

Posted: Wed Jul 03, 2019 8:17 pm
by daniel
Thanks for the feedback ;)