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

undefined reference



  • 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?


  • Lifetime Qt Champion

    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.



  • 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


  • Lifetime Qt Champion

    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 ?



  • @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



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


  • Lifetime Qt Champion

    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



  • i am controling



  • 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


  • Lifetime Qt Champion

    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.



  • 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));
    


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


  • Lifetime Qt Champion

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



  • fortunately :)


Log in to reply