Blame readme.md

Packit 2035a7
# **Cppcheck** 
Packit 2035a7
Packit 2035a7
|Linux Build Status|Windows Build Status|Coverity Scan Build Status|
Packit 2035a7
|:--:|:--:|:--:|
Packit 2035a7
|[![Linux Build Status](https://img.shields.io/travis/danmar/cppcheck/master.svg?label=Linux%20build)](https://travis-ci.org/danmar/cppcheck)|[![Windows Build Status](https://img.shields.io/appveyor/ci/danmar/cppcheck/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/danmar/cppcheck/branch/master)|[![Coverity Scan Build Status](https://img.shields.io/coverity/scan/512.svg)](https://scan.coverity.com/projects/512)|
Packit 2035a7
Packit 2035a7
## Donations
Packit 2035a7
Packit 2035a7
If you find Cppcheck useful for you, feel free to make a donation.
Packit 2035a7
Packit 2035a7
[![Donate](http://pledgie.com/campaigns/4127.png)](http://pledgie.com/campaigns/4127)
Packit 2035a7
Packit 2035a7
## About the name
Packit 2035a7
Packit 2035a7
The original name of this program was "C++check", but it was later changed to "Cppcheck".
Packit 2035a7
Packit 2035a7
Despite the name, Cppcheck is designed for both C and C++.
Packit 2035a7
Packit 2035a7
## Manual
Packit 2035a7
Packit 2035a7
A manual is available [online](http://cppcheck.sourceforge.net/manual.pdf).
Packit 2035a7
Packit 2035a7
## Compiling
Packit 2035a7
Packit 2035a7
Any C++11 compiler should work. For compilers with partial C++11 support it may work. If your compiler has the C++11 features that are available in Visual Studio 2010 then it will work. If nullptr is not supported by your compiler then this can be emulated using the header lib/cxx11emu.h.
Packit 2035a7
Packit 2035a7
To build the GUI, you need Qt.
Packit 2035a7
Packit 2035a7
When building the command line tool, [PCRE](http://www.pcre.org/) is optional. It is used if you build with rules.
Packit 2035a7
Packit 2035a7
There are multiple compilation choices:
Packit 2035a7
* qmake - cross platform build tool
Packit 2035a7
* cmake - cross platform build tool
Packit 2035a7
* Windows: Visual Studio (VS 2010 and above)
Packit 2035a7
* Windows: Qt Creator + mingw
Packit 2035a7
* gnu make
Packit 2035a7
* g++ 4.6 (or later)
Packit 2035a7
* clang++
Packit 2035a7
Packit 2035a7
### qmake
Packit 2035a7
Packit 2035a7
You can use the gui/gui.pro file to build the GUI.
Packit 2035a7
Packit 2035a7
```shell
Packit 2035a7
cd gui
Packit 2035a7
qmake
Packit 2035a7
make
Packit 2035a7
```
Packit 2035a7
Packit 2035a7
### Visual Studio
Packit 2035a7
Packit 2035a7
Use the cppcheck.sln file. The file is configured for Visual Studio 2015, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.
Packit 2035a7
Packit 2035a7
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.
Packit 2035a7
Packit 2035a7
### Qt Creator + MinGW
Packit 2035a7
Packit 2035a7
The PCRE dll is needed to build the CLI. It can be downloaded here:
Packit 2035a7
http://software-download.name/pcre-library-windows/
Packit 2035a7
Packit 2035a7
### GNU make
Packit 2035a7
Packit 2035a7
Simple, unoptimized build (no dependencies):
Packit 2035a7
Packit 2035a7
```shell
Packit 2035a7
make
Packit 2035a7
```
Packit 2035a7
Packit 2035a7
The recommended release build is:
Packit 2035a7
Packit 2035a7
```shell
Packit 2035a7
make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"
Packit 2035a7
```
Packit 2035a7
Packit 2035a7
Flags:
Packit 2035a7
Packit 2035a7
1.  `SRCDIR=build`  
Packit 2035a7
    Python is used to optimise cppcheck
Packit 2035a7
Packit 2035a7
2.  `CFGDIR=cfg`  
Packit 2035a7
    Specify folder where .cfg files are found
Packit 2035a7
Packit 2035a7
3.  `HAVE_RULES=yes`  
Packit 2035a7
    Enable rules (PCRE is required if this is used)
Packit 2035a7
Packit 2035a7
4.  `CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"`
Packit 2035a7
    Enables most compiler optimizations, disables cppcheck-internal debugging code and enables basic compiler warnings.
Packit 2035a7
Packit 2035a7
### g++ (for experts)
Packit 2035a7
Packit 2035a7
If you just want to build Cppcheck without dependencies then you can use this command:
Packit 2035a7
Packit 2035a7
```shell
Packit 2035a7
g++ -o cppcheck -std=c++0x -include lib/cxx11emu.h -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp
Packit 2035a7
```
Packit 2035a7
Packit 2035a7
If you want to use `--rule` and `--rule-file` then dependencies are needed:
Packit 2035a7
Packit 2035a7
```shell
Packit 2035a7
g++ -o cppcheck -std=c++0x -include lib/cxx11emu.h -lpcre -DHAVE_RULES -Ilib -Iexternals/simplecpp -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp
Packit 2035a7
```
Packit 2035a7
Packit 2035a7
### MinGW
Packit 2035a7
Packit 2035a7
```shell
Packit 2035a7
mingw32-make LDFLAGS=-lshlwapi
Packit 2035a7
```
Packit 2035a7
Packit 2035a7
### Other Compiler/IDE
Packit 2035a7
Packit 2035a7
1. Create a empty project file / makefile.
Packit 2035a7
2. Add all cpp files in the cppcheck cli and lib folders to the project file / makefile.
Packit 2035a7
3. Add all cpp files in the externals folders to the project file / makefile.
Packit 2035a7
4. Compile.
Packit 2035a7
Packit 2035a7
### Cross compiling Win32 (CLI) version of Cppcheck in Linux
Packit 2035a7
Packit 2035a7
```shell
Packit 2035a7
sudo apt-get install mingw32
Packit 2035a7
make CXX=i586-mingw32msvc-g++ LDFLAGS="-lshlwapi" RDYNAMIC=""
Packit 2035a7
mv cppcheck cppcheck.exe
Packit 2035a7
```
Packit 2035a7
Packit 2035a7
## Webpage
Packit 2035a7
Packit 2035a7
http://cppcheck.sourceforge.net/