Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

Capturing your build settings for QNX Momentics

Capturing your build settings for QNX Momentics

Before analyzing C/C++ projects in QNX Momentics, you must customize the IDE build process to improve the capture of build settings.

Klocwork requires a build specification to perform an analysis. The build specification contains a list of the project's source files and their compiler options (includes and defines). Klocwork creates the build specification by monitoring the IDE build process or by monitoring an external (command-line) build process. The former is recommended as it automatically updates the build specification when files are added or removed from the project.

Before you begin

Make sure you use Java the appropriate version of Java

QNX Momentics 4.6 and 4.7 use Java 5 by default. The Klocwork Eclipse plug-in requires Java 7. Specify the JVM for Momentics 4.6 and 4.7 in the qde.ini file (for example, \QNX650\host\win32\x86\usr\qde\eclipse\qde.ini) by adding the following two lines to the beginning of the file:

-vm
<jvm_install_path>\bin

Make sure you're using a supported builder

Momentics uses three types of builders to make C/C++ projects. (Eclipse C/C++ projects use #2 and #3.)

  1. QNX Recursive Make Builder
    • Mandatory for QNX C/C++ projects with Momentics 4.7
  2. Gnu Make Builder
    • Selectable for C/C++ projects
  3. Internal CDT Builder for C/C++ projects
    • Selectable for C/C++ projects

If a project is being built with the "Internal CDT Builder", then you need to change its build type. Klocwork requires the "QNX Recursive Make Builder" or the "Gnu Make Builder" be specified to automatically produce an accurate build specification. You select the builder for a project with the C/C++ Build/Tool Chain Editor properties page.

Continue to the next section or skip to Gnu Make Builder.

QNX Recursive Make Builder

Monitoring the QNX Recursive make process requires a command/shell file be created on your machine because of how Momentics sets the MAKE environment variable. The command/shell file sets MAKE to the correct value.

Create the command/shell file kwinjectqnx

Before you can create the command/shell file, you must ensure you have the command line desktop analysis tools installed. For more information, see Downloading and deploying the desktop analysis plug-ins

Windows: Create a kwinjectqnx.bat file and place it in the <command_line_tools>\bin directory (for example, C:\Klocwork\Klocwork 2018.1 Command Line\bin). The kwinjectqnx.bat file should contain two lines:

set MAKE=%1
kwinject -u -o buildspec.out %*

Linux: Create an executable kwinjectqnx.sh file and place it in the <command_line_tools>/bin directory (for example, /opt/tools/klocwork/commandlinetools/bin). The kwinjectqnx.sh file should contain three lines:

MAKE=$1
export MAKE
kwinject -u -o buildspec.out $*

Modify each project's Build Command

In the Momentics Project Explorer, select each C/C++ project in turn and view the C/C++ Build tab of the project properties.

In the Momentics Project Explorer, select each QNX C/C++ project in turn and view the Make Builder tab of the project properties.

Deselect Use Default Build command and add the appropriate command/shell in front of the existing Build Command contents. For example:

Windows

${system_path:kwinjectqnx.bat} ${QNX_HOST}/usr/bin/make ...

Linux

${system_path:kwinjectqnx.sh} ${QNX_HOST}/usr/bin/make ...

Build each project

Build each project in turn by doing a Clean followed by a Build. Verify that there are no build errors in the Momentics Console window.

Modify each project's Klocwork Build settings

To modify each project's Klocwork Build Settings to use the build specification (buildspec.out) generated by the previous steps:

  1. In the Klocwork Build Settings page of the project properties, select Use build specification file.
  2. Enter the location of the build specification file (buildspec.out). This file must be unique for each project. The previous steps cause the file to be created in the root of the project's Momentics source tree (that is, where the project's makefile is located). Clicking Browse automatically brings you to this folder. Note that the build specification file won't exist until after the project is cleaned and built.

Now go back to Connect to a project on the Klocwork Server.

Gnu Make Builder

The Gnu Make Builder changes are simpler because the make process is not recursive.

Modify each project's Build Command

In the Momentics Project Explorer, select each C/C++ project in turn and view the C/C++ Build project properties page.

Deselect the Use Default Build command and add the kwinject command, and its arguments, in front of the existing Build Command contents. For example:

${system_path:kwinject} -u -o ${ProjDirPath}/buildspec.out make ...

Build each project

Build each project in turn by doing a Clean followed by a Build. Verify that there are no build errors in the Momentics Console window.

Modify each project's Klocwork Build settings

To modify each project's Klocwork Build Settings to use the build specification (buildspec.out) generated by the previous steps:

  1. In the Klocwork Build Settings page of the project properties, select Use build specification file.
  2. Enter the location of the build specification file (buildspec.out). This file must be unique for each project. The previous steps cause the file to be created in the root of the project's Momentics source tree (that is, where the project's makefile is located). Clicking Browse automatically brings you to this folder. Note that the build specification file won't exist until after the project is cleaned and built.

Now go back to Connect to a project on the Klocwork Server.