Quick start of PVS-Studio C/C++ on Linux and macOS
- License file information
- Integration into development environments
- How to use pvs-studio-analyzer
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.
License file information
Integration into development environments
PVS-Studio has plugins for the following development environments:
How to use pvs-studio-analyzer
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.
How to generate JSON Compilation Database (Linux, macOS)
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.
Compilation tracing (Linux only)
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.
How to start project analysis
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 \
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.
How to handle analysis results
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 \
The analyzer warnings are saved in the specified Analysis_Report.json file.