Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: Evaluation - 05.12

>
Quick start of PVS-Studio C/C++ on Linu…

Quick start of PVS-Studio C/C++ on Linux and macOS

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.

Introduction

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

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.

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 \
                            -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.

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 \
               /path/to/PVS-Studio.log

The analyzer warnings are saved in the specified Analysis_Report.json file.