Results 1 to 3 of 3

Thread: QBENCHMARK resulting in undefined reference problems

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QBENCHMARK resulting in undefined reference problems

    Hello!

    I'm trying to build a benchmark application for some tests with Qt. I was going to use QElapsedTimer when I found this article (http://qt-project.org/doc/qt-4.8/qte...tutorial5.html) telling about the usage of QBENCHMARK macro for doing such a work. I tried to implement it in my code after including QtTest (using Qt 4.8) and Qt Creator returned me lots of undefined reference errors.

    Qt Code:
    1. //in .cpp
    2. #include <QtTest/QtTest>
    3.  
    4. using namespace QTest;
    5.  
    6. //...
    7.  
    8. void MainWindow::on_startQBenchmark_clicked()
    9. {
    10. QBENCHMARK {
    11. int aaa = 0;
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    Image:
    Screenshot from 2014-06-27 10:56:40.jpg

    I can't understand why is that happening

    Thanks,

    Momergil


    Edit: I noticed now that the compiler errors appears even if I don't call QBENCHMARK.
    Last edited by Momergil; 27th June 2014 at 15:03.
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QBENCHMARK resulting in undefined reference problems

    Have you added
    Qt Code:
    1. QT += testlib
    To copy to clipboard, switch view to plain text mode 
    to your .pro file?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Momergil (27th June 2014)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QBENCHMARK resulting in undefined reference problems

    Quote Originally Posted by anda_skoa View Post
    Qt Code:
    1. QT += testlib
    To copy to clipboard, switch view to plain text mode 
    That did the trick


    Thanks,

    Momergil



    Edit: or not... only half of it :T Now it compiles fine, but I receive a segmentation fault (pointing to the macro) each time I try to run it, even using the exact same code of the page linked above. =/
    Last edited by Momergil; 27th June 2014 at 17:52.
    May the Lord be with you. Always.

Similar Threads

  1. undefined reference
    By deepakswaroop in forum Newbie
    Replies: 1
    Last Post: 2nd March 2011, 06:46
  2. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 13:04
  3. undefined reference
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2009, 13:45
  4. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  5. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 10:21

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.