开发者

When I run cxxtest I get an undefined reference error

I'm not sure to understand the undefined reference I am getting.

./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… u开发者_如何学JAVAndefined 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.h

DrawTestSuite.h contains the unit-test and The test function calls on Linewidth.h to execute the constructer and member function draw.

I have #include "Linewidth.h"in DrawTestSuite.h.


"Undefined reference" is a linker error when a function has been properly declared and used, but the definition has not been included when linking.

You need to link with Linewidth.o, which is the object file from compiling Linewdith.cpp and the likely location where those functions are implemented.

I'm not familiar with cxxtest to know how it expects you to specify that dependency, but I suspect it only requires a simple declaration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜