PDA

View Full Version : QBENCHMARK resulting in undefined reference problems



Momergil
27th June 2014, 14:59
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/qtestlib-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.



//in .cpp
#include <QtTest/QtTest>

using namespace QTest;

//...

void MainWindow::on_startQBenchmark_clicked()
{
QBENCHMARK {
int aaa = 0;
}
}


Image:
10463

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.

anda_skoa
27th June 2014, 15:08
Have you added


QT += testlib

to your .pro file?

Cheers,
_

Momergil
27th June 2014, 17:48
QT += testlib


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. =/