Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

First define here



  • Good morning. I have such a problem...

    MinGw:

    ./build\help.o:help.cpp:(.text+0x0): multiple definition of `Help::Help(QWidget*)'
    ./build\help.o:help.cpp:(.text+0x0): first defined here
    ./build\help.o:help.cpp:(.text+0x0): multiple definition of `Help::Help(QWidget*)'
    ./build\help.o:help.cpp:(.text+0x0): first defined here
    ./build\help.o:help.cpp:(.text+0x180): multiple definition of `Help::~Help()'
    ./build\help.o:help.cpp:(.text+0x180): first defined here
    ./build\help.o:help.cpp:(.text+0x1b0): multiple definition of `non-virtual thunk to Help::~Help()'
    ./build\help.o:help.cpp:(.text+0x1b0): first defined here
    ./build\help.o:help.cpp:(.text+0x180): multiple definition of `Help::~Help()'
    ./build\help.o:help.cpp:(.text+0x180): first defined here
    ./build\help.o:help.cpp:(.text+0x1c0): multiple definition of `Help::~Help()'
    ./build\help.o:help.cpp:(.text+0x1c0): first defined here
    ./build\help.o:help.cpp:(.text+0x1e0): multiple definition of `non-virtual thunk to Help::~Help()'
    ./build\help.o:help.cpp:(.text+0x1e0): first defined here
    ./build\help.o:help.cpp:(.text+0x1f0): multiple definition of `Help::begin() const'
    ./build\help.o:help.cpp:(.text+0x1f0): first defined here
    ./build\help.o:help.cpp:(.text+0x210): multiple definition of `Help::end() const'
    ./build\help.o:help.cpp:(.text+0x210): first defined here
    C:/Qt/Qt5.4.1/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: ./build\help.o: bad reloc address 0x18 in section `.text$_ZN7Ui_Help7setupUiEP7QDialog[__ZN7Ui_Help7setupUiEP7QDialog]'
    collect2.exe: error: ld returned 1 exit status
    make[1]: *** [Makefile.Release:310: release\sosp.exe] Error 1
    

    My help.cpp:

    #include "help.h"
     
    #include <ui_help.h>
     
    Help::Help(QWidget *parent)
        : QDialog(parent)
        , ui(new Ui::Help)
    {
        ui->setupUi(this);
     
        ui->beginDE->setMaximumDate( QDateTime::currentDateTime().date() );  //два dateEdit 
        ui->beginDE->setDate( QDateTime::currentDateTime().date() );
     
        ui->endDE->setMaximumDate( QDateTime::currentDateTime().date() );
        ui->endDE->setDate( QDateTime::currentDateTime().date() );
    }
     
    Help::~Help()
    {
        delete ui;
    }
     
    QDate Help::begin() const
    {
        return ui->beginDE->date();
    }
     
    QDate Help::end() const
    {
        return ui->endDE->date();
    }
    
    My help.h:
    
    
    #pragma once
     
    #include <QDialog>
    #include <QDateTime>
     
    namespace Ui { class Help; }
     
    class Help : public QDialog
    {
        Q_OBJECT
    public:
        explicit Help(QWidget *parent = 0);
        ~Help();
     
        QDate begin() const;
        QDate end() const;
     
    private:
        Ui::Help * ui;
    };
    

    Main.cpp functional:

    void MainWindow::view_help()
    {
        if ( !checkPwd() ) return;
     
       Help * dialog = new Help( this );
        if ( dialog->exec() )
        {
            CrewTableViewerWidget * viewer = new CrewTableViewerWidget(this);
            viewer->setConfig( _editorConfig );
            viewer->setTimeInterval( dialog->begin(), dialog->end() );
            viewer->setCrew( getCrewIndex() );
            viewer->show();
        }
        dialog->deleteLater();
    }
    

    Also, there are .h and .cpp files that have the same functionality, but they work well.
    What could be the problem?


  • Lifetime Qt Champion

    @Mr_Steve make sure help.cpp is not added multiple times to your .pro file

    Regards



  • @aha_1980 Thanks! It-s work.



  • @Mr_Steve is your issue solved? If so please don't forget to mark your post as such. Thanks.


Log in to reply