I'm trying to get UnitTest++ to work in a project following this directory tree:
Project/
|-- src/
|-- test/
| |-- test.cpp
|-- unittest-cpp/
| |-- UnitTest++/
| |-- libUnitTest++.a
| |-- src/
| |-- UnitTest++.h
|-- Makefile
I'm trying to compile with g++ while in the Project directory. My test.cpp file contains the UnitTest++ Getting Started code.
I tried the following:
g++ -Lunittest-cpp/UnitTest++/ -lUnitTest++ -Iunittest-cpp/UnitTest++/src/ \
test/test.cpp -o Test
If I understand well, -L is to give the path to the static library. -l (Small L) is for the library name and -I (Capital i) is for the include path.
I get two different results. It either tells me it cannot find the lib in /usr/bin/??? or it tells me that there are undefined references to unittest::*.
Is it because I'm giving a relative path to the library that it cannot compile? I'm new to using g++ through multiple directories and I'm trying to understand how it works before getting it to work in my Makefile.
[EDIT]: The test/test.cpp parameter had to be given before linking the libraries and headers. So, this worked:
g++ test/test.cpp -Lunittest-cpp/UnitTest++ -lUnitTest++ -Iunittest-cpp/UnitTest++/src -o Test
The file to compile (in this context test.cpp) has to be given before its dependancies when compiling. This worked:
g++ test/test.cpp -Lunittest-cpp/UnitTest++ -lUnitTest++ -Iunittest-cpp/UnitTest++/src -o Test