Results 1 to 4 of 4

Thread: Building a QT project with WAF

  1. #1
    Join Date
    Feb 2012
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Building a QT project with WAF

    I am trying to building my project using waf.The Project is complied properly but there is some link error.Its fails to link to with the Resources file (.qrc file)

    Qt Code:
    1. main.cpp.1.o: In function main': /home/sobingt/project/masterdetail/build/../main.cpp:20: undefined reference toqInitResources_masterdetail()'
    To copy to clipboard, switch view to plain text mode 

    WAF output --zones=deps

    Qt Code:
    1. sobingt@tuneb03-System-Product-Name:~/projects/masterdetail$ ./waf --zones=deps
    2. Waf: Entering directory `/home/sobingt/projects/masterdetail/build'
    3. 10:49:34 deps deps for [/home/sobingt/projects/masterdetail/main.cpp]: [/home/sobingt/projects/masterdetail/mainwindow.h, /home/sobingt/projects/masterdetail/listmodel.h, /home/sobingt/projects/masterdetail/cache.h, /home/sobingt/projects/masterdetail/tablemodel.h, /home/sobingt/projects/masterdetail/mytablemodel.h]; unresolved ['QApplication', 'QPalette', 'QPixmap', 'QSplashScreen', 'qthread.h', 'boost/scoped_ptr.hpp', 'QMainWindow', 'QModelIndex', 'QAbstractListModel', 'QList', 'QVariant', 'tr1/unordered_map', 'QAbstractTableModel', 'QStringList', 'iostream', 'sstream', 'vector']
    4. 10:49:34 deps scanner for qxx: main.cpp -> build/main.cpp.1.o returned [/home/sobingt/projects/masterdetail/mainwindow.h, /home/sobingt/projects/masterdetail/listmodel.h, /home/sobingt/projects/masterdetail/cache.h, /home/sobingt/projects/masterdetail/tablemodel.h, /home/sobingt/projects/masterdetail/mytablemodel.h] ['QApplication', 'QPalette', 'QPixmap', 'QSplashScreen', 'qthread.h', 'boost/scoped_ptr.hpp', 'QMainWindow', 'QModelIndex', 'QAbstractListModel', 'QList', 'QVariant', 'tr1/unordered_map', 'QAbstractTableModel', 'QStringList', 'iostream', 'sstream', 'vector']
    5. [14/15] qxx: main.cpp -> build/main.cpp.1.o
    6. [15/15] cxxprogram: build/main.cpp.1.o build/mainwindow.cpp.1.o build/masterdetail_rc.o build/cache.cpp.1.o build/listmodel.cpp.1.o build/model.cpp.1.o build/mysortfilterproxymodel.cpp.1.o build/mytablemodel.cpp.1.o build/song.cpp.1.o build/songitem.cpp.1.o build/songs.cpp.1.o build/tablemodel.cpp.1.o build/tableproxymodel.cpp.1.o -> build/app
    7. main.cpp.1.o: In function `main':
    8. /home/sobingt/projects/masterdetail/build/../main.cpp:20: undefined reference to `qInitResources_masterdetail()'
    9. main.cpp.1.o: In function `~MainWindow':
    10. /home/sobingt/projects/masterdetail/build/../mainwindow.h:22: undefined reference to `vtable for MainWindow'
    11. /home/sobingt/projects/masterdetail/build/../mainwindow.h:22: undefined reference to `vtable for MainWindow'
    12. mainwindow.cpp.1.o: In function `MainWindow':
    13. /home/sobingt/projects/masterdetail/build/../mainwindow.cpp:22: undefined reference to `vtable for MainWindow'
    14. /home/sobingt/projects/masterdetail/build/../mainwindow.cpp:22: undefined reference to `vtable for MainWindow'
    15. mainwindow.cpp.1.o: In function `ListItem':
    16. /home/sobingt/projects/masterdetail/build/../listmodel.h:14: undefined reference to `vtable for ListItem'
    17. mainwindow.cpp.1.o: In function `MainWindow::tr(char const*, char const*)':
    18. /home/sobingt/projects/masterdetail/build/../mainwindow.h:24: undefined reference to `MainWindow::staticMetaObject'
    19. mainwindow.cpp.1.o: In function `SongItem':
    20. /home/sobingt/projects/masterdetail/build/../songitem.h:17: undefined reference to `vtable for SongItem'
    21. listmodel.cpp.1.o: In function `ListModel':
    22. /home/sobingt/projects/masterdetail/build/../listmodel.cpp:7: undefined reference to `vtable for ListModel'
    23. listmodel.cpp.1.o: In function `~ListModel':
    24. /home/sobingt/projects/masterdetail/build/../listmodel.cpp:27: undefined reference to `vtable for ListModel'
    25. mysortfilterproxymodel.cpp.1.o: In function `MySortFilterProxyModel':
    26. /home/sobingt/projects/masterdetail/build/../mysortfilterproxymodel.cpp:4: undefined reference to `vtable for MySortFilterProxyModel'
    27. mytablemodel.cpp.1.o: In function `MyTableModel':
    28. /home/sobingt/projects/masterdetail/build/../mytablemodel.cpp:3: undefined reference to `vtable for MyTableModel'
    29. tablemodel.cpp.1.o: In function `TableModel':
    30. /home/sobingt/projects/masterdetail/build/../tablemodel.cpp:9: undefined reference to `vtable for TableModel'
    31. collect2: ld returned 1 exit status
    32. Waf: Leaving directory `/home/sobingt/projects/masterdetail/build'
    33. Build failed
    34. -> task failed (exit status 1):
    35. {task 14658768: cxxprogram main.cpp.1.o,mainwindow.cpp.1.o,masterdetail_rc.o,cache.cpp.1.o,listmodel.cpp.1.o,model.cpp.1.o,mysortfilterproxymodel.cpp.1.o,mytablemodel.cpp.1.o,song.cpp.1.o,songitem.cpp.1.o,songs.cpp.1.o,tablemodel.cpp.1.o,tableproxymodel.cpp.1.o -> app}
    36. ['/usr/bin/g++', 'main.cpp.1.o', 'mainwindow.cpp.1.o', 'masterdetail_rc.o', 'cache.cpp.1.o', 'listmodel.cpp.1.o', 'model.cpp.1.o', 'mysortfilterproxymodel.cpp.1.o', 'mytablemodel.cpp.1.o', 'song.cpp.1.o', 'songitem.cpp.1.o', 'songs.cpp.1.o', 'tablemodel.cpp.1.o', 'tableproxymodel.cpp.1.o', '-o', '/home/sobingt/projects/masterdetail/build/app', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-lQtCore', '-lQtGui', '-lQtCore', '-lQtOpenGL', '-lQtGui', '-lQtCore', '-lQtSvg', '-lQtGui', '-lQtCore', '-lQtSql', '-lQtCore', '-lQtUiTools', '-lQtXml', '-lQtCore', '-lQtScript', '-lQtCore']
    To copy to clipboard, switch view to plain text mode 

    wscript file

    Qt Code:
    1. VERSION='0.0.1'
    2. APPNAME='qt4_test'
    3.  
    4. top = '.'
    5. out = 'build'
    6.  
    7. def options(opt):
    8. opt.load('compiler_cxx qt4')
    9.  
    10. def configure(conf):
    11. conf.load('compiler_cxx qt4')
    12. conf.env.append_value('CXXFLAGS', ['-g']) # test
    13.  
    14. def build(bld):
    15. def build(bld):
    16. bld(
    17. features = 'qt4 cxx',
    18. uselib = 'QTCORE QTGUI QTOPENGL QTSVG QWIDGET QTSQL QTUITOOLS QTSCRIPT',
    19. includes = bld.env.INCLUDES_QTGUI,
    20. source = 'mainwindow.cpp masterdetail.qrc cache.cpp listmodel.cpp model.cpp mysortfilterproxymodel.cpp mytablemodel.cpp song.cpp songitem.cpp songs.cpp tablemodel.cpp tableproxymodel.cpp',
    21. target = 'mainwindow.o',
    22. )
    23. bld(
    24. features = 'qt4 cxx cxxprogram',
    25. uselib = 'QTCORE QTGUI QTOPENGL QTSVG QWIDGET QTSQL QTUITOOLS QTSCRIPT',
    26. includes = bld.env.INCLUDES_QTGUI,
    27. source = 'main.cpp',
    28. target = 'app',
    29. use = 'mainwindow.o',
    30.  
    31. )
    To copy to clipboard, switch view to plain text mode 

    project file structure

    Qt Code:
    1. ├── build
    2. │ ├── c4che
    3. │ │ ├── build.config.py
    4. │ │ └── _cache.py
    5. │ ├── config.log
    6. │ ├── main.cpp.1.o
    7. │ ├── masterdetail_rc.cpp
    8. │ └── masterdetail_rc.o
    9. ├── cache.cpp
    10. ├── cache.h
    11. ├── images
    12. │ ├── betaLogo.png
    13. │ ├── exitButton.gif
    14. │ ├── icon.png
    15. │ ├── image.png
    16. │ ├── mas.png
    17. │ ├── play.png
    18. │ ├── saveButton.png
    19. │ ├── stopbutton.png
    20. │ └── stop.png
    21. ├── listmodel.cpp
    22. ├── listmodel.h
    23. ├── main.cpp
    24. ├── mainwindow.cpp
    25. ├── mainwindow.h
    26. ├── Makefile
    27. ├── masterdetail64.png
    28. ├── masterdetail80.png
    29. ├── masterdetail.desktop
    30. ├── masterdetail_harmattan.desktop
    31. ├── masterdetail.pro
    32. ├── masterdetail.pro.user
    33. ├── masterdetail.qrc
    34. ├── masterdetail.svg
    35. ├── model.cpp
    36. ├── model.h
    37. ├── mysortfilterproxymodel.cpp
    38. ├── mysortfilterproxymodel.h
    39. ├── mytablemodel.cpp
    40. ├── mytablemodel.h
    41. ├── repository.db
    42. ├── song.cpp
    43. ├── song.h
    44. ├── songitem.cpp
    45. ├── songitem.h
    46. ├── songs.cpp
    47. ├── songs.h
    48. ├── tablemodel.cpp
    49. ├── tablemodel.h
    50. ├── tableproxymodel.cpp
    51. ├── tableproxymodel.h
    52. ├── tableUnit.cpp
    53. ├── waf
    54. ├── waf-1.6.11
    55. ├── wscript
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Building a QT project with WAF

    Where does your build process run rcc on the qrc file and include the result into the sources to be built?
    Where does your build process run moc on the header files and include the result into the sources to be built?
    Last edited by ChrisW67; 16th March 2012 at 07:34.

  3. #3
    Join Date
    Feb 2012
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Building a QT project with WAF

    i didnot get you? You want me to also put the the source codes...i am not using moc.....i am a newbie so sorry if i wrote something stupid


    Added after 6 minutes:


    The error is during linking it to a executable object app
    cxxprogram: build/main.cpp.2.o build/mainwindow.cpp.1.o build/masterdetail_rc.o build/cache.cpp.1.o build/listmodel.cpp.1.o build/model.cpp.1.o build/mysortfilterproxymodel.cpp.1.o build/mytablemodel.cpp.1.o build/song.cpp.1.o build/songitem.cpp.1.o build/songs.cpp.1.o build/tablemodel.cpp.1.o build/tableproxymodel.cpp.1.o -> build/app
    main.cpp
    #include <QApplication>

    #include <QPalette>
    #include <QPixmap>
    #include <QSplashScreen>
    #include <qthread.h>
    #include "boost/scoped_ptr.hpp"
    #include "mainwindow.h"

    class I : public QThread
    {
    public:
    static void sleep(unsigned long secs) {
    QThread::sleep(secs);
    }
    };

    int main(int argc, char *argv[])
    {
    Q_INIT_RESOURCE(masterdetail);

    QApplication app(argc, argv);

    QPixmap pixmap(":/images/betaLogo.png");
    QSplashScreen splash(pixmap);
    splash.show();
    splash.showMessage("Loading...");
    qApp->processEvents();
    I::sleep(2);//delay 2 sec
    QPalette pal = app.palette();
    pal.setColor(QPalette::Window, Qt::AA_MacPluginApplication);
    app.setPalette(pal);

    MainWindow window("artists", "albums");
    window.show();
    splash.finish(&window);//Makes the splash screen wait until the widget mainWin is displayed
    return app.exec();
    }

    Added after 8 minutes:


    how do i use the Resource Compiler (rcc) output...the .rcc file

    i just used
    Qt Code:
    1. rcc -binary masterdetail.qrc -o masterdetail.rcc
    To copy to clipboard, switch view to plain text mode 
    Last edited by learningqt; 16th March 2012 at 07:52.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Building a QT project with WAF

    You need to run moc on any header (or source) file containing a Q_OBJECT macro. Not doing this is the source of all the "vtable" errors in your original post.
    Qt Code:
    1. moc -o moc_something.cpp something.h
    To copy to clipboard, switch view to plain text mode 
    and then the moc_something.cpp has to be added to the sources being built.

    The resource compiler:
    Qt Code:
    1. rcc -o something.cpp something.qrc
    To copy to clipboard, switch view to plain text mode 
    and then the something.cpp has to be added to the sources being built.

    I am sure the qt4 support of WAF has some way of doing this for you, but I do not propose to learn WAF just to find out.

Similar Threads

  1. error while building qt project
    By bibhukalyana in forum Newbie
    Replies: 2
    Last Post: 9th May 2011, 04:19
  2. Error while building project
    By kapitanluffy in forum Newbie
    Replies: 1
    Last Post: 9th February 2011, 13:33
  3. Project Building
    By .:saeed:. in forum Newbie
    Replies: 0
    Last Post: 3rd February 2011, 10:04
  4. Qt 4.3.2 + eclipse 3.3 first project building
    By christauffre in forum Newbie
    Replies: 2
    Last Post: 5th December 2007, 13:52
  5. Building the entire project
    By vermarajeev in forum Qt Programming
    Replies: 14
    Last Post: 28th February 2007, 04:00

Tags for this Thread

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.