Page 1 of 2

problem of integrating Qt files

Posted: Thu Jul 21, 2016 4:10 pm
by Lucien
I had these errors with my plugin generated by CMake
1>------ Début de la génération : Projet : QIRCLOUD_PLUGIN, Configuration : Release Win32 ------
1>QIRCLOUD_PLUGIN_automoc.obj : error LNK2005: "public: virtual struct QMetaObject const * __thiscall MainWindow::metaObject(void)const " (?metaObject@MainWindow@@UBEPBUQMetaObject@@XZ) déjà défini(e) dans moc_mainwindow.obj
1>QIRCLOUD_PLUGIN_automoc.obj : error LNK2005: "public: virtual int __thiscall MainWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@MainWindow@@UAEHW4Call@QMetaObject@@HPAPAX@Z) déjà défini(e) dans moc_mainwindow.obj
1>QIRCLOUD_PLUGIN_automoc.obj : error LNK2005: "public: virtual void * __thiscall MainWindow::qt_metacast(char const *)" (?qt_metacast@MainWindow@@UAEPAXPBD@Z) déjà défini(e) dans moc_mainwindow.obj
1>QIRCLOUD_PLUGIN_automoc.obj : error LNK2005: "private: static void __cdecl MainWindow::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@MainWindow@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z) déjà défini(e) dans moc_mainwindow.obj
1>QIRCLOUD_PLUGIN_automoc.obj : error LNK2005: "public: static struct QMetaObject const MainWindow::staticMetaObject" (?staticMetaObject@MainWindow@@2UQMetaObject@@B) déjà défini(e) dans moc_mainwindow.obj
1> Création de la bibliothèque C:/ysong/CloudCompare/trunk-2.6.3.1/build/plugins/qIRCloud/Release/QIRCLOUD_PLUGIN.lib et de l'objet C:/ysong/CloudCompare/trunk-2.6.3.1/build/plugins/qIRCloud/Release/QIRCLOUD_PLUGIN.exp
1>C:\ysong\CloudCompare\trunk-2.6.3.1\build\plugins\qIRCloud\Release\QIRCLOUD_PLUGIN.dll : fatal error LNK1169: un ou plusieurs symboles définis à différentes reprises ont été rencontrés
========== Génération : 0 a réussi, 1 a échoué, 12 mis à jour, 0 a été ignoré ==========
Capture01.PNG
Capture01.PNG (10.12 KiB) Viewed 11271 times
its strange that two "ui_mainwindow.h" are created.

I tried also to import my Qt files without Cmake
(" mainwindow.h"; "mainwindow.cpp"; "ui_mainwindow.h"; "mainwindow.ui" and "moc_mainwindow.cpp"),
and this time, it worked.

I don't understand why since I had the same files

Re: problem of integrating Qt files

Posted: Thu Jul 21, 2016 4:48 pm
by daniel
Strange indeed... did you use the default CMake script for your plugin? Can you post it here?

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 6:53 am
by Lucien
cmake_minimum_required(VERSION 2.8)

option( INSTALL_QIRCLOUD_PLUGIN "Check to install qIRCLOUD plugin" OFF )

if (INSTALL_QIRCLOUD_PLUGIN)

project(QIRCLOUD_PLUGIN )

include( ../CMakePluginTpl.cmake )

endif()
Here is my cmake file for plugin

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 7:00 am
by daniel
Nothing fancy then ;)

Maybe it's because of the fact that CloudCompare already has a 'mainwindow.h' file? CMake may be confused...

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 7:26 am
by Lucien
I changed the name but had the same problem

Here are files in my plugin.
Capture02.PNG
Capture02.PNG (15.39 KiB) Viewed 11261 times

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 7:53 am
by daniel
One last option: have you set the same build and source directory in CMake maybe?

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 8:15 am
by Lucien
Capture03.PNG
Capture03.PNG (3.49 KiB) Viewed 11257 times
I think It should not be this.

I will do other tests to find the problem.
Alternatively, I can work with Qt manually imported at the moment.

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 8:25 am
by daniel
You should never set the build directory below the source one (I think there's even a warning that should appear in CMake console... but I admit it's a bit flooded by other warnings ;).

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 9:17 am
by Lucien
Capture04.PNG
Capture04.PNG (3.09 KiB) Viewed 11252 times
Capture05.PNG
Capture05.PNG (18.07 KiB) Viewed 11252 times
it's strange that it imports even not the same files with these in my plugin document. I don't understand how cmake searches it.

Re: problem of integrating Qt files

Posted: Fri Jul 22, 2016 9:32 am
by Lucien
I found it. I shouldn't have put the moc_.. and ui_.. files in my plugin.