我如何告诉lcov在哪里找到我的。cpp和。h文件?

时间:2023-01-13 10:31:05

My source and build tree looks like this (see Makefile to put object files from source files different directories into a single, separate directory?) after a make (which builds and runs FooAndBarTests):

我的源代码和构建树看起来是这样的(见Makefile将目标文件从源文件中放入不同的目录到一个单独的目录中),然后在make(构建和运行FooAndBarTests)之后:

src
- Foo.cpp
- Bar.cpp
inc
- Foo.h
- Bar.h
test
- FooTest.cpp
- BarTest.cpp
- Main.cpp
- Makefile
- obj
  - Foo.gcda
  - Foo.gcno
  - Bar.gcda
  - Bar.gcno
- FooAndBarTests
UnitTest++
- libUnitTest++.a
- src
  - ...

I can then produce .gcov files in the test directory by running gcov -o obj/ ../src/Foo.cpp and gcov -o obj/ ../src/Bar.cpp.

然后,我可以通过运行gcov -o obj/ ./src/Foo来在测试目录中生成.gcov文件。cpp和gcov -o obj/ ./src/Bar.cpp。

But if I run lcov -d obj/ -c -o FooAndBarTests.lcov I get:

但如果我运行lcov -d obj/ -c -o FooAndBarTests。lcov得到:

Capturing coverage data from obj/
Found gcov version: 4.2.1
Scanning obj/ for .gcda files ...
Found 4 data files in obj/
Processing Foo.gcda
../src/Foo.cpp:cannot open source file
Processing FooTest.gcda
FooTest.cpp:cannot open source file
../inc/Foo.h:cannot open source file
../UnitTest++/src/Checks.h:cannot open source file
...

And then when I run genhtml FooAndBarTests.lcov I get:

然后当我运行genhtml FooAndBarTests时。lcov得到:

Reading data file FooAndBarTests.lcov
Found 45 entries.
Found common filename prefix "/Users/dspitzer/FooAndBar/test"
Writing .css and .png files.
Generating output.
Processing file UnitTest++/src/Checks.h
genhtml: ERROR: cannot open /Users/dspitzer/FooAndBar/test/UnitTest++/src/Checks.h for reading!

How do I tell lcov and genhtml where the .cpp and .h files are?

我如何告诉lcov和genhtml,其中。cpp和。h文件是什么?

1 个解决方案

#1


14  

Use the -b option to lcov. The -b option specifies code base.

使用-b选项对lcov。b选项指定代码库。

#1


14  

Use the -b option to lcov. The -b option specifies code base.

使用-b选项对lcov。b选项指定代码库。