CPROVER now needs a C++11 compliant compiler and works in the following environments:
- Linux
- MacOS X
- Solaris 11
- FreeBSD 11
- Cygwin
- Microsoft Visual Studio
The rest of this document is split up into three parts: compilation on Linux, MacOS, Windows. Please read the section appropriate for your machine.
We assume that you have a Debian/Ubuntu or Red Hat-like distribution.
-
You need a C/C++ compiler, Flex and Bison, and GNU make. The GNU Make needs to be version 3.81 or higher. On Debian-like distributions, do as root:
apt-get install g++ gcc flex bison make git libwww-perl patch
On Red Hat/Fedora or derivates, do as root:
dnf install gcc gcc-c++ flex bison perl-libwww-perl patch
Note that you need g++ version 5.0 or newer.
On Amazon Linux and similar distributions, do as root:
yum install gcc72-c++ flex bison perl-libwww-perl patch tar
To compile JBMC, you additionally need the JDK and Maven 3. You also need jq if you wish to run the entire test suite. On Debian-like distributions, do as root:
apt-get install openjdk-8-jdk maven jq
On Red Hat/Fedora or derivates, do as root:
dnf install java-1.8.0-openjdk-devel maven jq
-
As a user, get the CBMC source via
git clone https://github.com/diffblue/cbmc cbmc-git cd cbmc-git
-
To compile, do
make -C src minisat2-download make -C src
See doc/architectural/compilation-and-development.md for instructions on how to use a SAT solver other than MiniSat 2.
-
To compile JBMC, do
make -C jbmc/src setup-submodules make -C jbmc/src
We assume Solaris 11.4 or newer. To build JBMC, you'll need to install Maven 3 manually.
- As root, get the necessary development tools:
pkg install gcc-c++-7 bison flex
- As a user, get the CBMC source via
git clone https://github.com/diffblue/cbmc cbmc-git cd cbmc-git
- To compile CBMC, type
gmake -C src minisat2-download DOWNLOADER=wget TAR=gtar gmake -C src
- To compile JBMC, type
gmake -C jbmc/src setup-submodules gmake -C jbmc/src
- As root, get the necessary tools:
To compile JBMC, additionally install
pkg install bash gmake git www/p5-libwww patch flex bison
pkg install openjdk8 wget maven3
- As a user, get the CBMC source via
git clone https://github.com/diffblue/cbmc cbmc-git cd cbmc-git
- To compile CBMC, do
gmake -C src minisat2-download gmake -C src
- To compile JBMC, do
gmake -C jbmc/src setup-submodules gmake -C jbmc/src
Follow these instructions:
- You need a C/C++ compiler, Flex and Bison, and GNU make. To this end, first
install the XCode from the App-store and then type
in a terminal window.
xcode-select --install
- Then get the CBMC source via
git clone https://github.com/diffblue/cbmc cbmc-git cd cbmc-git
- To compile CBMC, do
make -C src minisat2-download make -C src
- To compile JBMC, you additionally need Maven 3, which has to be installed
manually. Then do
make -C jbmc/src setup-submodules make -C jbmc/src
There are two options: the Visual Studio compiler with version 14 (2015) or later, or the MinGW cross compiler with version 5.4 or later. We recommend Visual Studio.
Follow these instructions:
- First install Cygwin, then from the Cygwin setup facility install the
following packages:
flex, bison, tar, gzip, git, make, wget, patch, libwww-perl
. - Get the CBMC source via
git clone https://github.com/diffblue/cbmc cbmc-git cd cbmc-git
- Depending on your choice of compiler:
- To compile with Visual Studio, change the second line of
src/config.inc
toOpen the Developer Command Prompt for Visual Studio, then start the Cygwin shell withBUILD_ENV = MSVC
bash.exe -login
- To compile with MinGW, use Cygwin setup to install a mingw g++ compiler
package, i.e. one of
mingw{32,64}-{x86_64,i686}-gcc-g++
. You may also have to adjust the section insrc/common
that definesCC
andCXX
for BUILD_ENV = Cygwin. Then start the Cygwin shell.
- To compile with Visual Studio, change the second line of
- To compile CMBC, open the Cygwin shell and type
make -C src DOWNLOADER=wget minisat2-download make -C src
- To compile JBMC, you additionally need the JDK and Maven 3, which have
to be installed manually. Then open the Cygwin shell and type
make -C jbmc/src setup-submodules make -C jbmc/src
(Optional) A Visual Studio project file can be generated with the script "generate_vcxproj" that is in the subdirectory "scripts". The project file is helpful for GUI-based tasks, e.g., the class viewer, debugging, etc., and can be used for building with MSBuild. Note that you still need to run flex/bison using "make generated_files" before opening the project.
There is also a build based on CMake instead of hand-written makefiles. It should work on a wider variety of systems than the standard makefile build, and can integrate better with IDEs and static-analysis tools. On Windows, the CMake build does not depend on Cygwin or MinGW, and doesn't require manual modification of build files.
-
Ensure you have all the build dependencies installed. Build dependencies are the same as for the makefile build, but with the addition of CMake version 3.2 or higher. The installed CMake version can be queried with
cmake --version
. To install cmake:- On Debian-like distributions, do
apt-get install cmake
- On Red Hat/Fedora or derivates, do
dnf install cmake
- On macOS, do
You shoud also install Homebrew, after which you can run
xcode-select --install
brew install cmake
to install CMake. - On platforms where installing the Java Development Kit and Maven is
difficult, you can avoid needing these dependencies by not building
JBMC. Just pass
-DWITH_JBMC=OFF
to cmake in step (4) below. - On Windows, ensure you have Visual Studio 2015 or later installed.
Then, download CMake from the official download
page.
You'll also need
git
andpatch
, which are both provided by the git for Windows package. Finally, Windows builds of flex and bison should be installed from the sourceforge page. The easiest way to 'install' these executables is to unzip them and to drop the entire unzipped package into the CBMC source directory. - Use of CMake has not been tested on Solaris or FreeBSD. However, it should be possible to install CMake from the system package manager or the official download page on those systems. The dependencies (as listed in the relevant sections above) will also be required, and should be installed using the suggested methods.
- On Debian-like distributions, do
-
Navigate to the top level folder of the project. This is different from the Makefile build, which requires you to navigate to the
src
directory first. -
Update git submodules:
git submodule update --init
-
Generate build files with CMake:
cmake -H. -Bbuild
This command tells CMake to use the configuration in the current directory, and to generate build files into the
build
directory. This is the point to specify custom build settings, such as compilers and build back-ends. You can use clang (for example) by adding the argument-DCMAKE_CXX_COMPILER=clang++
to the command line. You can also tell CMake to generate IDE projects by supplying the-G
flag. Runcmake -G
for a comprehensive list of supported back-ends.Generally it is not necessary to manually specify individual compiler or linker flags, as CMake defines a number of "build modes" including Debug and Release modes. To build in a particular mode, add the flag
-DCMAKE_BUILD_TYPE=Debug
(orRelease
) to the initial invocation.If you do need to manually add flags, use
-DCMAKE_CXX_FLAGS=...
and-DCMAKE_EXE_LINKER_FLAGS=...
. This is useful for enabling clang's sanitizers.Finally, to enable building universal binaries on macOS, you can pass the flag
-DCMAKE_OSX_ARCHITECTURES=i386;x86_64
. If you don't supply this flag, the build will just be for the architecture of your machine. -
Run the build:
cmake --build build
This command tells CMake to invoke the correct tool to run the build in the
build
directory. You can also use the build back-end directly by invokingmake
,ninja
, or opening the generated IDE project as appropriate.
To work with Eclipse, do the following:
- Select File -> New -> Makefile Project with Existing Code
- Type "cprover" as "Project Name"
- Select the "src" subdirectory as "Existing Code Location"
- Select a toolchain appropriate for your platform
- Click "Finish"
- Select Project -> Build All
You can also select the repository's root folder as the "Existing Code Location". This has the advantage that you can build both CBMC and JBMC without the need to integrate JBMC as a separate project. Be aware that you need to change the build location (Select project in Eclipse -> Properties -> C/C++ Build) to one of the src directories.
Cudd is a BDD library which can be used instead of the builtin miniBDD implementation.
If compiling with make:
- Download and compile Cudd:
make -C src cudd-download
- Uncomment the definition of
CUDD
in the filesrc/config.inc
. - Compile with
make -C src
If compiling with cmake:
- Add the
-DCMAKE_USE_CUDD=true
flag to thecmake
configuration phase. For instance:cmake -H. -Bbuild -DCMAKE_USE_CUDD=true
- Run the build:
cmake --build build
There are two implementation for symex guards. The default one uses the internal representation of expression. The other one uses BDDs and though experimental, it is expected to have better performance, in particular when used in conjunction with CUDD.
To use the BDD implementation of guards, add the BDD_GUARDS
compilation flag:
- If compiling with make:
make -C src CXXFLAGS="-O2 -DBDD_GUARDS"
- If compiling with CMake:
and then
cmake -H. -Bbuild -DCMAKE_CXX_FLAGS="-DBDD_GUARDS"
cmake --build build