You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,7 +20,8 @@ Cppcheck is a hobby project with limited resources. You can help us by donating
21
20
22
21
1. Download (and extract) Cppcheck source code.
23
22
2. Run (Linux/MacOS example):
24
-
```
23
+
24
+
```shell
25
25
cd cppcheck/
26
26
python3 -m venv .venv
27
27
source .venv/bin/activate
@@ -30,9 +30,9 @@ Cppcheck is a hobby project with limited resources. You can help us by donating
30
30
./tools/donate-cpu.py
31
31
```
32
32
33
-
The script will analyse debian source code and upload the results to a cppcheck server. We need these results both to improve Cppcheck and to detect regressions.
33
+
The script will analyse debian source code and upload the results to a Cppcheck server. We need these results both to improve Cppcheck and to detect regressions.
34
34
35
-
You can stop the script whenever you like with CtrlC.
35
+
You can stop the script whenever you like with Ctrl+C.
36
36
37
37
## Compiling
38
38
@@ -43,6 +43,7 @@ To build the GUI application, you need to use the CMake build system.
43
43
When building the command line tool, [PCRE](http://www.pcre.org/) is optional. It is used if you build with rules.
44
44
45
45
There are multiple compilation choices:
46
+
46
47
* CMake - cross platform build tool
47
48
* (Windows) Visual Studio
48
49
* (Windows) Qt Creator + MinGW
@@ -62,22 +63,22 @@ cmake --build build
62
63
```
63
64
64
65
If you want to compile the GUI you can use the flag.
65
-
-DBUILD_GUI=ON
66
+
`-DBUILD_GUI=ON`
66
67
67
68
For rules support (requires pcre) use the flag.
68
-
-DHAVE_RULES=ON
69
+
`-DHAVE_RULES=ON`
69
70
70
71
For release builds it is recommended that you use:
71
-
-DUSE_MATCHCOMPILER=ON
72
+
`-DUSE_MATCHCOMPILER=ON`
72
73
73
74
For building the tests use the flag.
74
-
-DBUILD_TESTING=ON
75
+
`-DBUILD_TESTING=ON`
75
76
76
-
Using cmake you can generate project files for Visual Studio,XCode,etc.
77
+
Using CMake you can generate project files for Visual Studio,XCode,etc.
77
78
78
79
#### Building a specific configuration
79
80
80
-
For single-configuration generators (like "Unix Makefiles") you can generate and build a specific configuration (e.g. "RelWithDebInfo") using:
81
+
For single-configuration generators (like "Unix Makefiles") you can generate and build a specific configuration (e.g. "`RelWithDebInfo`") using:
Use the cppcheck.sln file. The file is configured for Visual Studio 2019, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.
97
+
Use the `cppcheck.sln` file. The file is configured for Visual Studio 2019, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.
97
98
98
-
To compile with rules, select "Release-PCRE" or "Debug-PCRE" configuration. pcre.lib (pcre64.lib for x64 builds) and pcre.h are expected to be in /externals then. A current version of PCRE for Visual Studio can be obtained using [vcpkg](https://github.com/microsoft/vcpkg).
99
+
To compile with rules, select"`Release-PCRE`" or "`Debug-PCRE`" configuration. `pcre.lib` (`pcre64.lib`forx64 builds) and `pcre.h` are expected to bein`/externals` then. A current version of PCRE for Visual Studio can be obtained using [vcpkg](https://github.com/microsoft/vcpkg).
99
100
100
101
### Visual Studio (from command line)
101
102
102
-
If you do not wish to use the Visual Studio IDE, you can compile cppcheck from the command line the following command.
103
+
If you do not wish to use the Visual Studio IDE, you can compile Cppcheck from the command line the following command.
103
104
104
105
```shell
105
106
msbuild cppcheck.sln
106
107
```
107
108
108
109
### VS Code (on Windows)
109
110
110
-
Install MSYS2 to get GNU toolchain with g++ and gdb (https://www.msys2.org/).
111
-
Create a settings.json file in the .vscode folder with the following content (adjust path as necessary):
111
+
Install MSYS2 to get GNU toolchain with g++ and gdb (<https://www.msys2.org/>).
112
+
Create a `settings.json` file in the `.vscode` folder with the following content (adjust path as necessary):
@@ -123,11 +124,11 @@ Create a settings.json file in the .vscode folder with the following content (ad
123
124
}
124
125
```
125
126
126
-
Run "make" in the terminal to build cppcheck.
127
+
Run `make`in the terminal to build Cppcheck.
127
128
128
-
For debugging create a launch.json file in the .vscode folder with the following content, which covers configuration for debugging cppcheck and misra.py:
129
+
For debugging create a `launch.json` file in the `.vscode` folder with the following content, which covers configuration for debugging Cppcheck and `misra.py`:
129
130
130
-
```
131
+
```json
131
132
{
132
133
// Use IntelliSense to learn about possible attributes.
133
134
// Hover to view descriptions of existing attributes.
@@ -174,7 +175,7 @@ For debugging create a launch.json file in the .vscode folder with the following
174
175
### Qt Creator + MinGW
175
176
176
177
The PCRE dll is needed to build the CLI. It can be downloaded here:
Several `Token` matching patterns are converted into more efficient C++ code at compile time (requires Python to be installed).
209
210
210
-
-`FILESDIR=/usr/share/cppcheck`
211
-
Specifies the folder where cppcheck files (addons, cfg, platform) are installed to.
211
+
*`FILESDIR=/usr/share/cppcheck`
212
+
Specifies the folder where Cppcheck files (addons, cfg, platform) are installed to.
212
213
213
-
-`HAVE_RULES=yes`
214
+
*`HAVE_RULES=yes`
214
215
Enables rules (requires PCRE to be installed).
215
216
216
-
-`CXXOPTS="-O2"`
217
+
*`CXXOPTS="-O2"`
217
218
Enables most compiler optimizations.
218
219
219
-
-`CPPOPTS="-DNDEBUG"`
220
+
*`CPPOPTS="-DNDEBUG"`
220
221
Disables assertions.
221
222
222
-
-`HAVE_BOOST=yes`
223
+
*`HAVE_BOOST=yes`
223
224
Enables usage of more efficient container from Boost (requires Boost to be installed).
224
225
225
226
### MinGW
@@ -230,18 +231,18 @@ mingw32-make
230
231
231
232
If you encounter the following error with `MATCHCOMPILER=yes` you need to specify your Python interpreter via `PYTHON_INTERPRETER`.
232
233
233
-
```
234
+
```text
234
235
process_begin: CreateProcess(NULL, which python3, ...) failed.
235
236
makefile:24: pipe: No error
236
237
process_begin: CreateProcess(NULL, which python, ...) failed.
237
238
makefile:27: pipe: No error
238
239
makefile:30: *** Did not find a Python interpreter. Stop.
239
240
```
240
241
241
-
### Other Compiler/IDE
242
+
### Other compiler/IDE
242
243
243
244
1. Create an empty project file / makefile.
244
-
2. Add all cpp files in the cppcheck cli and lib folders to the project file / makefile.
245
+
2. Add all cpp files in the Cppcheck cli and lib folders to the project file / makefile.
245
246
3. Add all cpp files in the externals folders to the project file / makefile.
246
247
4. Compile.
247
248
@@ -255,41 +256,41 @@ mv cppcheck cppcheck.exe
255
256
256
257
## Packages
257
258
258
-
Besides building yourself on the platform of your choice there are also several ways to obtain pre-built packages.<br/>
259
+
Besides building yourself on the platform of your choice there are also several ways to obtain pre-built packages.
259
260
260
261
### Official
261
262
262
263
Official packages are maintained by the Cppcheck team.
263
264
264
-
- (Windows) An official Windows installer is available via the official Cppcheck SourceForge page: https://cppcheck.sourceforge.io.
265
-
- (Windows) Official builds of the current development versions are available via the [release-windows](https://github.com/danmar/cppcheck/actions/workflows/release-windows.yml) workflow. They are built nightly for the `main` branch and for each commit for release branches. As these are development versions please refrain from using these in production environments!
266
-
- A portable package (i.e. does not require installation) is available as the `portable` artifact. This is still a work-in-progress - see https://trac.cppcheck.net/ticket/10771 for details.
267
-
- An installer is available via the `installer` artifact.
268
-
- (Multi-Platform) A premium version with additional features provided by the original author of Cppcheck is available for purchase via https://www.cppcheck.com.
265
+
* (Windows) An official Windows installer is available via the official Cppcheck SourceForge page: <https://cppcheck.sourceforge.io>.
266
+
* (Windows) Official builds of the current development versions are available via the [release-windows](https://github.com/danmar/cppcheck/actions/workflows/release-windows.yml) workflow. They are built nightly forthe `main` branch and for each commit for release branches. As these are development versions please refrain from using thesein production environments!
267
+
* A portable package (i.e. does not require installation) is available as the `portable` artifact. This is still a work-in-progress - see <https://trac.cppcheck.net/ticket/10771>for details.
268
+
* An installer is available via the `installer` artifact.
269
+
* (Multi-Platform) A premium version with additional features provided by the original author of Cppcheck is available for purchase via <https://www.cppcheck.com>.
269
270
270
271
### Third-party
271
272
272
273
Third-party packages are ***not*** maintained by the Cppcheck team but their respective packagers.
273
274
274
275
*Note:* The following list is purely informational and listed in no particular order.
275
276
276
-
*Note:* Please always try to obtain the package from the primary official source of your operating system/distro first and make sure you are getting the latest released/tagged version (see https://github.com/danmar/cppcheck/tags). Some packages might not carry the latest patch version though.
277
+
*Note:* Please always try to obtain the package from the primary official source of your operating system/distro first and make sure you are getting the latest released/tagged version (see <https://github.com/danmar/cppcheck/tags>). Some packages might not carry the latest patch version though.
277
278
278
279
*Note:* Some issues might be related to additional patches carried by the builds in these packages or by the packaging itself. Please try to verify the issue with an official build before reporting it upstream. Otherwise you might need toreport it to the respective maintainer of the package.
279
280
280
-
- (Windows / Outdated) A portable package is available via https://portableapps.com/apps/development/cppcheck-portable.
281
-
- (Windows / Outdated) A package is available via https://community.chocolatey.org/packages/cppcheck.
282
-
- (Windows / Outdated) A package is available via https://winget.run/pkg/Cppcheck/Cppcheck.
283
-
- (Windows) A package is available via https://scoop.sh/#/apps?q=cppcheck.
284
-
- (Linux/Unix) Many major distros offer Cppcheck packages via their integrated package managers (`yum`, `apt`, `pacman`, etc.). See https://pkgs.org/search/?q=cppcheck or https://repology.org/project/cppcheck for an overview.
285
-
- (Linux/Unix) Unless you are using a "rolling" distro, it is likely that they are not carrying the latest version. There are several external (mainly unsupported) repositories like AUR (ArchLinux), PPA (ubuntu), EPEL (CentOS/Fedora) etc. which might provide up-to-date packages.
286
-
- (Linux/Unix / Outdated) The Canonical Snapcraft packages (https://snapcraft.io/cppcheck / https://snapcraft.io/cppcheckgui) are unmaintained and contain very old (development) versions. Please refrain from using them! See https://trac.cppcheck.net/ticket/11641 for more details.
287
-
- (MacOS) A package is available via Homebrew (`brew`). See https://formulae.brew.sh/formula/cppcheck.
288
-
- (MacOS) A package is available via https://ports.macports.org/port/cppcheck.
289
-
- (Multi-Platform) A package is available via https://anaconda.org/conda-forge/cppcheck.
290
-
- (Multi-Platform) A package is available via https://conan.io/center/recipes/cppcheck.
291
-
- Packages are also available from various download portals (mainly the Windows installer - sometimes re-packaged).
281
+
* (Windows / Outdated) A portable package is available via <https://portableapps.com/apps/development/cppcheck-portable>.
282
+
* (Windows / Outdated) A package is available via <https://community.chocolatey.org/packages/cppcheck>.
283
+
* (Windows / Outdated) A package is available via <https://winget.run/pkg/Cppcheck/Cppcheck>.
284
+
* (Windows) A package is available via <https://scoop.sh/#/apps?q=cppcheck>.
285
+
* (Linux/Unix) Many major distros offer Cppcheck packages via their integrated package managers (`yum`, `apt`, `pacman`, etc.). See <https://pkgs.org/search/?q=cppcheck> or <https://repology.org/project/cppcheck>for an overview.
286
+
* (Linux/Unix) Unless you are using a "rolling" distro, it is likely that they are not carrying the latest version. There are several external (mainly unsupported) repositories like AUR (ArchLinux), PPA (Ubuntu), EPEL (CentOS/Fedora) etc. which might provide up-to-date packages.
287
+
* (Linux/Unix / Outdated) The Canonical Snapcraft packages (<https://snapcraft.io/cppcheck> / <https://snapcraft.io/cppcheckgui>) are unmaintained and contain very old (development) versions. Please refrain from using them! See <https://trac.cppcheck.net/ticket/11641>for more details.
288
+
* (MacOS) A package is available via Homebrew (`brew`). See <https://formulae.brew.sh/formula/cppcheck>.
289
+
* (MacOS) A package is available via <https://ports.macports.org/port/cppcheck>.
290
+
* (Multi-Platform) A package is available via <https://anaconda.org/conda-forge/cppcheck>.
291
+
* (Multi-Platform) A package is available via <https://conan.io/center/recipes/cppcheck>.
292
+
* Packages are also available from various download portals (mainly the Windows installer - sometimes re-packaged).
0 commit comments