This guide will help you start a project analysis quickly. The page does not list all analyzer features. If you would like to learn more about other features, please consult the full documentation.
The PVS-Studio C/C++ static code analyzer on Linux and macOS is a console application named pvs-studio-analyzer that includes several auxiliary utilities. It can integrate into VS Code, Qt Creator, and CLion as a plugin. The plugins provide a user-friendly interface for analyzing projects. To start the analysis, you need a configured build environment for your project.
To try PVS-Studio, request a license in the form. For the information on how to enter the license on Linux and macOS, please consult the documentation.
PVS-Studio has plugins for the following development environments:
Before running the analysis, do one of the following steps to obtain the project build model.
Important note. The project must successfully compile and be built to be analyzed.
This page contains instructions for running the analysis based on the compile_commands.json files. It works with popular build tools such as CMake, Ninja, GNU Make, Qt Build System, and Xcode.
This mode requires the strace utility to be installed. The analyzer can use it to collect necessary information on the project compilation while the project is being built.
Execute the following command to build the project and track the progress of its compilation:
pvs-studio-analyzer trace [-o <FILE>] -- build_command
The build_command command is used for building the project, for example:
pvs-studio-analyzer trace -- cmake build .
By default, the strace_out file is created as a result of tracing. You can learn more about the tracing mode here.
After receiving the compilation trace file (strace_out) or the JSON Compilation Database (compile_commands.json), you can run the analysis by executing the following command:
pvs-studio-analyzer analyze -o /path/to/PVS-Studio.log \
-e /path/to/exclude-path \
-j <N>
The analyze command requires strace_out or compile_commands.json files in the current working directory. You can explicitly specify the location of these files using the --file (-f) flag.
To convert the analyzer report to various formats (*.xml, *.tasks, etc.), use plog-converter. You can read more about this utility here.
Here is an example of how to convert the analyzer report to the json format:
plog-converter -a GA:1,2 \
-t json \
-o /path/to/Analysis_Report.json \
/path/to/PVS-Studio.log
The analyzer warnings are saved in the specified Analysis_Report.json file.