我不确定是否能理解我得到的未定义的引用。
./cxxtest/cxxtestgen.py -o tests.cpp --error-printer DrawTestSuite.h
g++ -I./cxxtest/ -c tests.cpp
g++ -o tests tests.o Color.o
tests.o: In function `DrawTestSuite::testLinewidthOne()':
tests.cpp:(.text._ZN13DrawTestSuite16t… undefined reference to `Linewidth::Linewidth(double)'
tests.cpp:(.text._ZN13DrawTestSuite16t… undefined reference to `Linewidth::draw(std::basic_ostream<char… std::char_traits<char> >&)'
collect2: ld returned 1 exit status
make: *** [tests] Error 1// DrawTestSuite.hDrawTestSuite.h包含单元测试,测试函数调用Linewidth.h来执行构造函数和成员函数绘图。
我在DrawTestSuite.h中有#include "Linewidth.h"。
发布于 2010-04-14 14:36:39
“未定义的引用”是一个链接器错误,当一个函数被正确地声明和使用,但在链接时没有包括定义。
您需要链接到Linewidth.o,这是编译Linewdith.cpp的目标文件,也是实现这些函数的可能位置。
我不熟悉cxxtest,不知道它希望您如何指定该依赖项,但我怀疑它只需要一个简单的声明。
https://stackoverflow.com/questions/2635300
复制相似问题