Qt QCompare的未定义符号
使用QTestLib构建测试时,我得到Qt QCompare的未定义符号,qt,qtestlib,Qt,Qtestlib,使用QTestLib构建测试时,我得到qCompare函数的“未定义符号”错误: Undefined symbols for architecture x86_64: "__ZN5QTest8qCompareIimEEbRKT_RKT0_PKcS8_S8_i", referenced from: __ZN15MyTestClass22myTestFunctionEv in MyTestClass.o 您可以通过shell命令中的c++filt来破译损坏的符号: echo __Z
qCompare
函数的“未定义符号”错误:
Undefined symbols for architecture x86_64:
"__ZN5QTest8qCompareIimEEbRKT_RKT0_PKcS8_S8_i", referenced from:
__ZN15MyTestClass22myTestFunctionEv in MyTestClass.o
您可以通过shell命令中的
c++filt
来破译损坏的符号:
echo __ZN5QTest8qCompareIimEEbRKT_RKT0_PKcS8_S8_i | c++filt
。。。它打印这样的C++函数签名:
bool QTest::qCompare<int, unsigned long>(int const&, unsigned long const&, char const*, char const*, char const*, int)
boolqtest::qCompare(int常量&,无符号长常量&,char常量*,char常量*,char常量*,int)
QCOMPARE
宏的两个参数(即QCOMPARE
函数的两个模板参数)必须具有完全相同的类型。例如,如果一个是int
,另一个是size\t
,则会出现错误 …因此,解决方案是静态转换类型,或者,在文本的情况下,通过使用“0ul”等使用正确的类型。