mercredi 6 juillet 2016

When to link and when to include?

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 ?

Aucun commentaire:

Enregistrer un commentaire