Results 1 to 13 of 13

Thread: Undefined reference

  1. #1
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Undefined reference

    Hi. I've got a problem. When I tried to compile the program, there appear error:
    undefined reference to 'abcziom()' in maker.cpp. Here are those two files:
    Maker.cpp
    Qt Code:
    1. #include <QtGui>
    2.  
    3. #include "maker.h"
    4.  
    5. MainWindow::MainWindow(QMainWindow *parent)
    6. : QMainWindow(parent)
    7. {
    8. ui.setupUi(this);
    9. }
    10. void MainWindow::abcziom()
    11.  
    12. {
    13.  
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 
    Maker.h
    Qt Code:
    1. #ifndef MAKER_H
    2. #define MAKER_H
    3.  
    4. #include "ui_maker.h"
    5.  
    6.  
    7. class MainWindow : public QMainWindow, public Ui::MainWindow
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. MainWindow(QMainWindow *parent = 0);
    13.  
    14. private slots:
    15.  
    16. void abcziom();
    17.  
    18. private:
    19.  
    20. Ui::MainWindow ui;
    21. };
    22.  
    23. #endif
    To copy to clipboard, switch view to plain text mode 
    Main.cpp, and ui_maker.h which I won't post, becauce is not problematic relationship. I really don't know what is this error about. Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Undefined reference

    Are both files (Maker.h and Maker.cpp) listed in .pro?
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Undefined reference

    yes, they are

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Undefined reference

    Add
    Qt Code:
    1. #endif // MAKER_H
    To copy to clipboard, switch view to plain text mode 
    at the end of maker.h.
    J-P Nurmi

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined reference

    Quote Originally Posted by jpn View Post
    Add
    Qt Code:
    1. #endif // MAKER_H
    To copy to clipboard, switch view to plain text mode 
    at the end of maker.h.
    Isn't "#endif" already there?
    Anyway, make sure maker.h is moc'ed,

    Regards

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Undefined reference

    Quote Originally Posted by marcel View Post
    Isn't "#endif" already there?
    Heh, you're right. I managed to miss it, sorry.

    Edit: Salazaar, could you show us your .pro file?
    J-P Nurmi

  7. #7
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Undefined reference

    Sure.
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.01a) N 13. maj 20:51:00 2007
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET =
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9.  
    10. # Input
    11. RESOURCES = images.qrc
    12. HEADERS += maker.h ui_maker.h ui_about.h
    13. SOURCES += main.cpp maker.cpp
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Undefined reference

    Quote Originally Posted by Salazaar View Post
    HEADERS += maker.h ui_maker.h ui_about.h
    It should be:
    Qt Code:
    1. HEADERS += maker.h
    2. FORMS += maker.ui about.ui
    To copy to clipboard, switch view to plain text mode 
    This way qmake will generate ui_*.h file automatically every time you change the .ui file.

  9. #9
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Undefined reference

    This was created by qmake. And I was trying to compile other applications this qmake system and it was ok

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Undefined reference

    You should create project files with qmake before you start compilation, not after that. Then only update the file manually.

  11. #11
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Undefined reference

    Sure I create project file before compiling, that's the procedure.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Undefined reference

    If you did, you wouldn't end up with ui_*.h files in it as these are created by uic during compilation. Unless of course you added them manually.

  13. #13
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Undefined reference

    I've solved the problem (I don't know exactly how) but I still don't understand what was the problem about. I've got all my files and run qmake-project

Similar Threads

  1. Compiling error
    By Foobar in forum Newbie
    Replies: 2
    Last Post: 17th March 2007, 23:02
  2. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15
  3. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 19:36
  4. undefined reference to fftw libraries
    By kmyadam in forum General Programming
    Replies: 2
    Last Post: 9th March 2006, 01:01
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.