Sunday, 15 March 2015

UnitTest++ and g++ - Relative path to the library -



UnitTest++ and g++ - Relative path to the library -

i'm trying unittest++ work in project next directory tree:

project/ |-- src/ |-- test/ | |-- test.cpp |-- unittest-cpp/ | |-- unittest++/ | |-- libunittest++.a | |-- src/ | |-- unittest++.h |-- makefile

i'm trying compile g++ while in project directory. test.cpp file contains unittest++ getting started code.

i tried following:

g++ -lunittest-cpp/unittest++/ -lunittest++ -iunittest-cpp/unittest++/src/ \ test/test.cpp -o test

if understand well, -l give path static library. -l (small l) library name , -i (capital i) include path.

i 2 different results. either tells me cannot find lib in /usr/bin/??? or tells me there undefined references unittest::*.

is because i'm giving relative path library cannot compile? i'm new using g++ through multiple directories , i'm trying understand how works before getting work in makefile.

[edit]: test/test.cpp parameter had given before linking libraries , headers. so, worked:

g++ test/test.cpp -lunittest-cpp/unittest++ -lunittest++ -iunittest-cpp/unittest++/src -o test

the file compile (in context test.cpp) has given before dependancies when compiling. worked:

g++ test/test.cpp -lunittest-cpp/unittest++ -lunittest++ -iunittest-cpp/unittest++/src -o test

g++ unittest++

No comments:

Post a Comment