![](/img/trans.png)
[英]How do I layout my C++ program? (where should I put the .h and .cpp files?)
[英]How do I tell lcov where to find my .cpp & .h files?
我的源代码和构建树看起来像这样(请参阅Makefile 将不同目录中的源文件中的目标文件放入一个单独的目录? )
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
- ...
然后我可以通过运行gcov -o obj/ ../src/Foo.cpp
和gcov -o obj/ ../src/Bar.cpp
在 test 目录中生成 .gcov 文件。
但是如果我运行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
...
然后当我运行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!
我如何告诉 lcov 和 genhtml .cpp 和 .h 文件在哪里?
对lcov
使用-b
选项。 -b
选项指定代码库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.