6

我想将覆盖率用于静态分析,而我需要它用于 C++。由于我的项目使用 Android NDK,我将编译器配置为:

cov-configure –comptype gcc –compiler ~/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-4.6

然后我跑了cov-build –dir coverity ndk-build –j8 NDK_DEBUG=1

一切都在建立,但我有一个警告

*[*WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.**

所以我忽略了警告并跑了

cov-analyze –dir coverity –all
**Coverity Static Analysis for C/C++ version 6.6.1 on Linux 2.6.38-8-server x86_64
Internal version numbers: d614fc01a4 p-eureka-push-15003.308

Looking for translation units
Error: no matching translation units.**

那么我的编译器配置正确吗?之前有没有人为 Android NDK 配置过编译器?

4

4 回答 4

6

您表示编译器是~/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc-4.6

确保这是命令中正确的完整路径(可能替换 '~'?),并且arm-linux-androideabi-gcc-4.6正是用于编译的路径。

我遇到了同样的问题,因为 Coverity 期望使用 GCC,但我的构建使用了 cc!

然后我设置:

~/coverity-current/bin/cov-configure --compiler /usr/bin/cc --comptype gcc

它显示:

[WARNING] A template configuration is recommended for this compiler.
Add "--template" to your command line, or use one of the
template configuration shortcut command lines below:

  cov-configure --gcc      # GNU C/C++ compiler (gcc/g++)
  cov-configure --msvc     # Microsoft C/C++ compiler (cl)
  cov-configure --java     # Sun Java compiler (javac)

You must remove the specific configuration before re-running with "--template".
* Configuring /usr/bin/cc as a C compiler
[WARNING] Config gcc-config-2 already exists for cc gcc gcc-4.8 as gcc and will be reused. 
* Configuring /usr/bin/cc as a C++ compiler
[WARNING] Config g++-config-2 already exists for cc gcc gcc-4.8 as g++ and will be reused. 

Generated coverity_config.xml at location /home/default/cov-analysis-linux64-X.X.X/config/coverity_config.xml
Successfully generated configuration for the compilers: cc gcc gcc-4.8

cov-build 命令是:

../../coverity-current/bin/cov-build --dir ~/build_cov/myapp/cov-log-all-output make -C ~/build_cov/myapp

结果:

../../coverity-current/bin/cov-build --dir ~/build_cov/myapp/cov-log-all-output make -C ~/build_cov/myapp

[...]

76 C/C++ compilation units (100%) are ready for analysis
The cov-build utility completed successfully.

您在 cov-log-all-output/c/emit/pcname/ 中有一个更大的 emit-db 文件

于 2015-11-12T13:26:11.433 回答
4

您应该为 NDK 配置正确的编译器:

cov-configure --comptype gcc -compiler arm-linux-androideabi-gcc --template
于 2014-05-12T16:33:34.907 回答
1

在coverity/build-log.txt 中,您应该看到在构建期间执行的所有命令(查找“EXECUTING:”)。仔细检查编译器命令是否与您为 cov-configure 指定的编译器匹配。您可以配置多个编译器,配置通用 gcc(“cov-configure --gcc”)可能很有用。

请记住,如果您的 ndk-build 实际上没有构建任何东西,那么 cov-build 将给出类似的消息。换句话说,该消息并不总是表明存在问题——可能构建已完成,但实际上并未编译任何文件。

于 2014-01-28T19:26:56.580 回答
0

所以我只是遇到了同样的问题并解决了它。就我而言,make file 是问题所在,即使编译器配置正确,我也收到以下警告:

没有发出任何文件。这可能是由于您的配置有问题,或者因为您的构建命令实际上没有编译任何文件。请确保您已配置编译中实际使用的编译器。

make 文件包含一些目标,而不是我打算使用的目标。因此,如果您不确定 makefile 中定义的所有目标,只需删除它们并编译您需要的任何内容并知道..否则与其他人讨论剩余目标。

于 2017-03-13T11:01:17.130 回答