problem of integrating Qt files

Questions related to plugins development
Lucien
Posts: 37
Joined: Wed Jun 08, 2016 7:51 am

problem of integrating Qt files

Post 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 11170 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
daniel
Site Admin
Posts: 7674
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: problem of integrating Qt files

Post by daniel »

Strange indeed... did you use the default CMake script for your plugin? Can you post it here?
Daniel, CloudCompare admin
Lucien
Posts: 37
Joined: Wed Jun 08, 2016 7:51 am

Re: problem of integrating Qt files

Post 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
daniel
Site Admin
Posts: 7674
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: problem of integrating Qt files

Post by daniel »

Nothing fancy then ;)

Maybe it's because of the fact that CloudCompare already has a 'mainwindow.h' file? CMake may be confused...
Daniel, CloudCompare admin
Lucien
Posts: 37
Joined: Wed Jun 08, 2016 7:51 am

Re: problem of integrating Qt files

Post 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 11160 times
daniel
Site Admin
Posts: 7674
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: problem of integrating Qt files

Post by daniel »

One last option: have you set the same build and source directory in CMake maybe?
Daniel, CloudCompare admin
Lucien
Posts: 37
Joined: Wed Jun 08, 2016 7:51 am

Re: problem of integrating Qt files

Post by Lucien »

Capture03.PNG
Capture03.PNG (3.49 KiB) Viewed 11156 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.
daniel
Site Admin
Posts: 7674
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: problem of integrating Qt files

Post 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 ;).
Daniel, CloudCompare admin
Lucien
Posts: 37
Joined: Wed Jun 08, 2016 7:51 am

Re: problem of integrating Qt files

Post by Lucien »

Capture04.PNG
Capture04.PNG (3.09 KiB) Viewed 11151 times
Capture05.PNG
Capture05.PNG (18.07 KiB) Viewed 11151 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.
Lucien
Posts: 37
Joined: Wed Jun 08, 2016 7:51 am

Re: problem of integrating Qt files

Post by Lucien »

I found it. I shouldn't have put the moc_.. and ui_.. files in my plugin.
Last edited by Lucien on Fri Jul 22, 2016 2:14 pm, edited 1 time in total.
Post Reply