gcov:从共享库生成.gcda输出? [英] gcov: producing .gcda output from shared library?

查看:826
本文介绍了gcov:从共享库生成.gcda输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以通过运行链接到使用--coverage选项构建的共享库的可执行文件来生成gcov数据文件(.gcda文件)。

Is it possible to produce gcov data files (.gcda files) by running an executable linked to a shared library built with the --coverage option?

基本上,我有主库包括多个c ++文件编译成一个共享库,然后一个名为test的子目录,包含一个测试程序,链接到和测试主库。一切编译正常,并为库源文件和测试源文件生成.gcno文件。 .gcda文件只是为测试源文件生成的,但我真正需要他们的实际源文件编译到共享库。

Basically, I have the main library consisting of multiple c++ files compiled into one shared library and then a subdirectory called "test" containing a test program that links to and tests the main library. Everything compiles fine and the .gcno files are produced for both the library source files and the test source files. The .gcda files are only produced for the test source files though, but I really need them for the actual source files that are compiled into the shared library.

任何想法?

其他信息:

- 这是所有的C ++代码

- 一切正在使用由automake生成的make脚本>
- 为共享库中的lib_la_CPPFLAGS和lib_la_LDFLAGS指定了--coverage选项Makefile.am

- 为测试可执行文件中的AM_CPPFLAGS和AM_LDFLAGS指定了--coverage选项Makefile.am < br>
- 测试源文件使用Google Test(C ++单元测试框架)

Additional info:
- It's all C++ code
- Everything is being build with make scripts generated by automake
- The --coverage option is specified for lib_la_CPPFLAGS and lib_la_LDFLAGS in the shared library Makefile.am
- The --coverage option is specified for AM_CPPFLAGS and AM_LDFLAGS in test executable Makefile.am
- The test source files make use of Google Test (a C++ Unit Testing Framework)

编辑:固定间距问题

推荐答案

我终于解决了这个问题,从gcc家伙一些帮助。请在这里查看主题: http://gcc.gnu.org/ml/gcc-help /2010-09/msg00130.html

I finally solved this problem by getting some help from the gcc guys. See the thread here: http://gcc.gnu.org/ml/gcc-help/2010-09/msg00130.html.

事实证明.gcda文件被放在.libs目录中,因为那是共享库(.so)文件。为了得到gcov产生输出,我不得不将.gcda文件上移一级到源文件的位置。

It turns out that the .gcda files were being put in the .libs directory since that's where the shared library (.so) files were. In order to get gcov to produce the output, I had to move the .gcda files up one level to where the source files were.

此外,这里有一个类似的线程其他人遇到了一些相同的问题: http://stackoverflow.com/问题/ 3709699 / can-gcov-deal-with-shared-object /

Also, here's a similar thread where someone else was running into some of the same problems: http://stackoverflow.com/questions/3709699/can-gcov-deal-with-shared-object/.

这篇关于gcov:从共享库生成.gcda输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆