简体   繁体   中英

codelite unittest++/UnitTest++.h: no such file or directory

I am trying to do unit testing with C++/Codelite. I have UnitTest++ plugin installed from codelite-plugins package (Ubuntu 18.04). I can also see this:

$ ls -la /usr/include | grep Unit
drwxr-xr-x  3 root root   4096 Mar  2 11:47 UnitTest++

$ sudo dpkg -l | grep unittest++
ii  libunittest++-dev         2.0.0-2      amd64        unit testing framework for c++, static library and headers
ii  libunittest++2:amd64      2.0.0-2      amd64        unit testing framework for c++, runtime library

So I create a test project in Codelite and I add this:

#include <unittest++/UnitTest++.h> // This line and main are auto-created

TEST(SanityTest) 
{
    CHECK_EQUAL(1, 1);
}

int main(int argc, char **argv)
{
    return UnitTest::RunAllTests();
}

Now I would expect test results after I press CTRL+F5. But when I do, I only get a popup window saying there are no tests:

在此处输入图片说明

I also noticed that when I go to Build > Build Project I get an error message:

fatal error: unittest++/UnitTest++.h: No such file or directory

I also found THIS ANSWER and tried different variation of console commands as per answer/comments there, but I always get the same no such file or directory error.

Any idea what I am missing?

EDIT:

Build log as per Stephen's Newell request:

/bin/sh -c '/usr/bin/make -j8 -e -f  Makefile'
----------Building project:[ Test - Debug ]----------
make[1]: Entering directory '/home/callmebob/Documents/workspace-codelite/cpp/Test'
/usr/bin/g++  -c  "/home/callmebob/Documents/workspace-codelite/cpp/Test/main.cpp" -g  -o Debug/main.cpp.o -I. -I/usr/include/unittest++
/home/callmebob/Documents/workspace-codelite/cpp/Test/main.cpp:1:10: fatal error: unittest++/UnitTest++.h: No such file or directory
 #include "unittest++/UnitTest++.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Test.mk:95: recipe for target 'Debug/main.cpp.o' failed
make[1]: *** [Debug/main.cpp.o] Error 1
make[1]: Leaving directory '/home/callmebob/Documents/workspace-codelite/cpp/Test'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
====2 errors, 0 warnings====

Also if I right-click the project, go to Settings > Compiler , I can see:

Included Paths = /usr/include/unittest++

Based on your ls output, it looks like you should change your first line to this:

#include <UnitTest++/UnitTest++.h>

I'm not sure why the answer you linked to worked with a lowercase directory name; the examples in the project documentation all use the mixed-case directory name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM