Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. undefined reference
Forum Update on Monday, May 27th 2025

undefined reference

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    veysel.olgun
    wrote on last edited by veysel.olgun
    #1

    Hello everyone i am about to my project anf-d i am getting that error :
    /home/veysel/Desktop/bitirme_yazilim_nobet/QTableWidget/widget.cpp:517: error: undefined reference to `Widget::kontrol(int, int)'

    i'm calling that if(kontrol(rastgele_dizi_elemani,j)==1).... in Widget::nobet_gunleri_belirle()
    i am using Ubuntu 18.01 and using Qt Creator 4.8.2 Based on Qt 5.12.2

    can anyone help me please?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you implement that method ?

      By the way, why do you have a folder named "QTableWidget" ? That's really not a good idea since it's also a Qt class.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • V Offline
        V Offline
        veysel.olgun
        wrote on last edited by
        #3

        Hi, i implemented the function and i defined it in header file and i have changed the name as proje but it is not work i am getting same error

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          hi
          can you show the kontrol function from both header and cpp ?
          it says it has none that take 2 ints.
          so i wonder if rastgele_dizi_elemani is an int ?

          1 Reply Last reply
          0
          • V Offline
            V Offline
            veysel.olgun
            wrote on last edited by veysel.olgun
            #5

            @SGaist said in undefined reference:

            way, why do you have a folder named "
            this is kontrol function :

            int kontrol(int rastgele_eleman,int indis_vektor)// i1 i>0 durumu için kontrol
            {
               int durum;
                if((gecici_haftaici_gunleritut.contains(rastgele_eleman+1)==true ||
                        gecici_haftaici_gunleritut.contains(rastgele_eleman-1)==true ||
                          secilen_ozelgunler[indis_vektor]==(rastgele_eleman-1) ||
                            secilen_ozelgunler[indis_vektor]==(rastgele_eleman+1))==1)
                {
                         durum=1;
                }
                else
                {
                durum=0;
                }
            
            
                return durum;
            }
            
            

            this is header file :

              int kontrol(int,int);
            

            and rastgele_eleman is integer as random value between (0-31), indis_vektor is indeks of loop

            1 Reply Last reply
            0
            • V Offline
              V Offline
              veysel.olgun
              wrote on last edited by veysel.olgun
              #6

              by the way i changed return value as boolean and modified header file. but it did not work

              1 Reply Last reply
              1
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                Hi
                Looks fine.
                so is kontrol(int rastgele_eleman,int indis_vektor) in same file that you call it ?

                i wonder why it says `Widget::kontrol(int, int)' in error when its clearly not part of Widget.

                Did you declare it inside of a class in .h or or outside ?

                i wonder if it should be
                int Widget::kontrol(int rastgele_eleman,int indis_vektor)// i1 i>0 durumu için kontrol
                { ...
                in the cpp

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  veysel.olgun
                  wrote on last edited by
                  #8

                  i am controling

                  1 Reply Last reply
                  1
                  • V Offline
                    V Offline
                    veysel.olgun
                    wrote on last edited by veysel.olgun
                    #9
                    namespace Ui {
                    class Widget;
                    }
                    
                    class Widget : public QWidget
                    {
                        Q_OBJECT
                       
                    
                    public:
                        explicit Widget(QWidget *parent = 0);
                        ~Widget();
                        int boyut_hafta_sonu();
                        int boyut_hafta_ici();
                        QVector<int> aylarin_haftasonlarini_al() const;
                        QVector<int> secilen_ayi_al();
                        int sirasini_bul(QVector<int> &,int);
                        void ozel_gun_nobeti_belirle();
                        int kontrol(int,int);
                        int kontrol_son_adim(int,int);
                       
                    }
                    

                    this is header file

                    1 Reply Last reply
                    1
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Ok :)
                      super, the issue is you forgot to mention Widget:: for its
                      implementation in cpp
                      You showed
                      int kontrol(int rastgele_eleman,int indis_vektor)// i1 i>0 durumu için kontrol
                      {
                      but it should have been

                      int Widget::kontrol(int rastgele_eleman,int indis_vektor)// i1 i>0 durumu için kontrol
                      {

                      since it belongs to the Widget class.

                      1 Reply Last reply
                      2
                      • V Offline
                        V Offline
                        veysel.olgun
                        wrote on last edited by veysel.olgun
                        #11

                        in addition that, my sirasini_bul function working in void Widget::nobet_gunleri_belirle()

                         secilen_ay.erase(secilen_ay.begin()+sirasini_bul(secilen_ay,rastgele_dizi_elemani));
                        
                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          veysel.olgun
                          wrote on last edited by
                          #12

                          Thank you so much, how did i forget this :( it is working now. thank you for all of you

                          mrjjM 1 Reply Last reply
                          0
                          • V veysel.olgun

                            Thank you so much, how did i forget this :( it is working now. thank you for all of you

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @veysel.olgun
                            well shit happens :)
                            Good it was something simple to fix

                            1 Reply Last reply
                            1
                            • V Offline
                              V Offline
                              veysel.olgun
                              wrote on last edited by
                              #14

                              fortunately :)

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved