0

I am working on a requirement to do instrumented build for c++ code on coverity(static code analysis tool, version 7.5.1) build server via command line. Need to execute a basic c++ code via command line, I tried using the cov-build command cov-build –-dir cov-int cl /c test.cpp and various other permutations on the directory where coverity is actually installed in the build machine. But there is some problem. System can understand only the cov-buld --dir and if i use only this command along with /c, this file opens in visual studio rather than giving the% of compilation units. Please help me if anyone have done this before.

Vinay Shukla
  • 1,818
  • 13
  • 41
Gitanshu Amola
  • 1
  • 1
  • 2
  • 3
  • cov-build requires two mandatory parameters cov-build --dir Have you provided intermediate_directory name? what is cov-int in the command mentioned by you? – Shrikant May 20 '15 at 10:28
  • Hi thanks for the answer, cov-int is our intermediate directory at the server for the respective project. Can you please tell me cl /c is a build command in coverity? Because every time I am getting the same error that cl is not a build command. for cov-int I am giving the complete directiry after dir. – Gitanshu Amola May 20 '15 at 12:51
  • on the same location where I have created this .cpp file a folder is created with name co-int which contains build-id, build-log, build cwd etc.. – Gitanshu Amola May 20 '15 at 12:54
  • cl /c is not any command in coverity, its a compiler name, you have to provide your build command as a second parameter. We use gmake command, cov-build --dir gmake -s release . – Shrikant May 21 '15 at 11:06

1 Answers1

0

First be clear with your requirements. Which system you are working on?(windows or Mac or Unix or Solaris). Before starting cov-build, configure the compiler which will execute the source file. As you said you are working on C++ source code, use GCC compiler to configure with Coverity Static Analyzer. Coverity Directly supports for 3 Compilers(Gcc and 2 more). To configure this GCC use cov-configure command followed by gcc.

Then use cov-build command to analyze.

Sample command is:

path_to_cov_bin/cov-build --dir path_to_output_folder gcc hi.cpp

It will create emit folder with emit-db in path_to_output_folder. Then cov-analyze command will be analyze that emit folder and create Output Directory in given path.

To compile N number of source files use makefile. If you have any query about makefile You can put a post here or refer in this site.

Sivanantham M
  • 91
  • 1
  • 8
  • Hi, I am working on windows. This compiler is already configured in the machine, I can see it in the coverity wizard so do i need to configure it again on command line ? Also when I am running the command suggested by you to configure the compiler system is giving the error: "you didn't specify a compiler". – Gitanshu Amola May 22 '15 at 08:43
  • path_to_cov_bin/cov-configure --gcc @GitanshuAmola – Sivanantham M May 22 '15 at 10:44
  • To compile more than one source file use makefile. Refer how to use makefile in windows @ [http://stackoverflow.com/questions/2532234/how-to-run-a-makefile-in-windows] – Sivanantham M May 22 '15 at 10:53
  • After you use the command cov-configure --gcc, It will show that you configured GCC compiler successfully. – Sivanantham M May 22 '15 at 10:55
  • As expected system told that the compiler is already configured. So gcc is configured that is clear now. – Gitanshu Amola May 22 '15 at 11:48
  • Then I again tried to execute the command "path_to_cov_bin/cov-build --dir D:\Test gcc test.cpp", but system is now giving error that gcc is not a build command. – Gitanshu Amola May 22 '15 at 11:50
  • here D:\Test is my output folder and test.cpp is my cpp file. – Gitanshu Amola May 22 '15 at 11:51
  • path_to_cov_bin/cov-build --dir D:\Test gcc test.cpp In this command you have to add path of the test.cpp file. – Sivanantham M May 22 '15 at 12:45
  • Example: path_to_cov_bin/cov-build --dir D:\Test gcc path_to_the_file/test.cpp – Sivanantham M May 22 '15 at 12:45
  • I was making one mistake. This command executed in visual studio command prompt !!! "cov-build --dir cl /c test.cpp”. – Gitanshu Amola Jun 23 '15 at 13:02