Klocwork documentation


Klocwork University
View detailed technical videos on Klocwork tools on the Klocwork Universtity page.

Tips for Eclipse users

Generating a C/C++ build spec with Eclipse

With many IDEs, Klocwork Desktop Analysis generates automatic build specification files as part of its defect detection process. In the case of Eclipse, this can prove to be quite a challenge. Klocwork relies on the Eclipse CDT indexer to generate the build specification. This can create inaccuracies and invalid results. To overcome this, Klocwork highly recommends you create a build specification manually and specify it separately in the project properties.

Alternatively a more automated approach would be:

1. In Eclipse, go to Project Properties > C/C++ Build > Tool Chain Editor and change the Current Builder for your active configuration to "Gnu Make Builder" from "CDT Internal Builder"

2. In Eclipse project properties, go to C/C++ Build > Builder Settings, uncheck "use default build command", and replace "make" (or the corresponding build command) with the following:
    <path to klocwork user installation>/bin/kwinject -u -o ${ProjDirPath}/kwinject.out make

3. Clean and build project (from main menu, Project > Clean, then Project > Build Project). The build specification must be created under the project directory. (The "clean" build is performed only once to create the full build specification. After that, "kwinject -u" should follow the project builds and update the build specification when files are added, deleted, etc.)

4. Project properties > Klocwork build settings > Use build specification file; point to the build specification file in your project directory.

When Klocwork Desktop Analysis runs, you are guaranteed to have a valid build specification with proper accuracy.