Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined symbols for QCompare

Tags:

qt

qtestlib

When building a test with QTestLib, I get an "undefined symbols" error for a qCompare function:

Undefined symbols for architecture x86_64:
  "__ZN5QTest8qCompareIimEEbRKT_RKT0_PKcS8_S8_i", referenced from:
      __ZN15MyTestClass22myTestFunctionEv in MyTestClass.o
like image 368
jlstrecker Avatar asked Jan 07 '13 15:01

jlstrecker


1 Answers

You can decipher the mangled symbol by passing it through c++filt in a shell command:

echo __ZN5QTest8qCompareIimEEbRKT_RKT0_PKcS8_S8_i | c++filt

... which prints a C++ function signature like this:

bool QTest::qCompare<int, unsigned long>(int const&, unsigned long const&, char const*, char const*, char const*, int)

The two arguments to the QCOMPARE macro — i.e., the two template arguments to the qCompare function — must have exactly the same type. You get an error, for example, if one is an int and the other is a size_t.

like image 77
jlstrecker Avatar answered Nov 18 '22 15:11

jlstrecker