2014-01-27 106 views
6

我想使用覆蓋度來進行靜態分析,並且我需要它用於C++。由於我的項目採用了Android NDK,我配置了編譯器爲:爲ndk-build配置覆蓋率

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配置過編譯器?

回答

1

在coverity/build-log.txt中,您應該看到構建期間執行的所有命令(查找「EXECUTING:」)。仔細檢查編譯器命令是否與您指定的編譯器匹配以配置cov。您可以配置多個編譯器,並且配置一個通用gcc(「cov-configure --gcc」)可能會很有用。

請記住,如果你的ndk-build實際上沒有構建任何東西,那麼cov-build會給出類似的信息。換句話說,這個消息並不總是表明一個問題 - 構建完成並且實際上沒有編譯任何文件是可能的。

+0

嗨,謝謝你的回覆。編譯完成後,它會在libs文件夾下生成.so文件。我看到編譯器命令是正確的。編譯器的路徑也是正確的。你能否澄清一下,當ndk-build不編譯任何文件時,它意味着什麼。再次感謝 – largotiticaca

4

你應該配置正確的編譯器NDK:

cov-configure --comptype gcc -compiler arm-linux-androideabi-gcc --template 
+0

正是! 編譯器名稱很重要。 有關更多詳細信息,請參閱Coverity文檔! – Tama

5

您指示Coverity的編譯器是〜/ Android的NDK-R8E /工具鏈/ ARM-Linux的androideabi-4.6 /預建/ 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. 

你有一個更大的EMIT-DB文件COV-LOG-全輸出/ C /發射/ pcname/

0

於是我就面臨着同樣的問題,並解決它。 在我的情況下make文件是問題,即使編譯器配置是正確的,我得到以下警告:

沒有文件被髮射。這可能是由於您的配置 存在問題,或者因爲您的build命令沒有真正編譯文件。 請確保您已經配置了編譯中實際使用的編譯器。

使文件包含一些目標,而不是我的意思是使用..所以,如果你不確定在makefile中定義的所有目標只是刪除它們並編譯你需要的任何東西,並意識到..與其他人討論關於剩餘目標。