0

I was writing a test case for a simple c++ program using CppUnit API. my program is four files:

  • Calc.h : Defines the class with the methods to test
  • TestCalc.h/cpp : Defines/impelents the class which tests the methods of Calc
  • runTestCalc.cpp: Main function which executes the test.

I installed the CppUnit and it has the files under:

/usr/local/include/cppunit and /usr/include/cppunit

the libs under /usr/lib :

libcppunit-1.13.so.0 
libcppunit.a
libcppunit.so
...

The question I have is how to compile this example assuming the proper CppUnit header files are properly included in the sources

I tried this:

g++ -I/usr/include/cppunit/ runTestCalc.cpp TestCalc.cpp

The other question is when to do

-I/to/include/ -L/to/lib

When to link ?

3
  • 1
    You'll need to do both in most cases. Commented Jun 19, 2016 at 22:09
  • @πάνταῥεῖ so how do you compile in this case Commented Jun 19, 2016 at 22:16
  • Provide all of the compiler/liker flags together? Commented Jun 19, 2016 at 22:18

1 Answer 1

1

c++ runTestCalc.cpp TestCalc.cpp -o runTestCalc -l cppunit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.