Skip to content

Commit 99592b3

Browse files
author
Daniel Kroening
authored
Merge pull request #1504 from andreast271/update-windows-build
Update documentation for building cbmc on windows.
2 parents bc3bc8f + dff22b8 commit 99592b3

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

COMPILING.md

+28-32
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ environments:
77
- MacOS X
88
- Solaris 11
99
- FreeBSD 11
10-
- Cygwin (We recommend the i686-pc-mingw32-g++ cross compiler, version 5.4 or
11-
above.)
12-
- Microsoft's Visual Studio version 12 (2013), version 14 (2015), or version 15
13-
(older versions won't work)
10+
- Cygwin
11+
- Microsoft Visual Studio
1412

1513
The rest of this document is split up into three parts: compilation on Linux,
1614
MacOS, Windows. Please read the section appropriate for your machine.
@@ -119,42 +117,40 @@ Follow these instructions:
119117

120118
# COMPILATION ON WINDOWS
121119

122-
There are two options: compilation using g++ from Cygwin, or using Visual
123-
Studio's compiler. As Cygwin has significant overhead during process creation,
124-
we advise you use Visual Studio.
120+
There are two options: the Visual Studio compiler with version 12 (2013) or
121+
later, or the MinGW cross compiler with version 5.4 or later.
122+
We recommend Visual Studio.
125123

126124
Follow these instructions:
127125

128-
1. You need a C/C++ compiler, Flex and Bison, GNU tar, gzip2, GNU make, and
129-
patch. The GNU Make needs to be version 3.81 or higher. If you don't
130-
already have the above, we recommend you install Cygwin.
131-
2. You need a SAT solver (in source). We recommend MiniSat2. Using a
132-
browser, download from
126+
1. First install Cygwin, then from the Cygwin setup facility install the
127+
following packages: `flex, bison, tar, gzip, git, make, wget, patch`.
128+
2. Get the CBMC source via
133129
```
134-
http://ftp.debian.org/debian/pool/main/m/minisat2/minisat2_2.2.1.orig.tar.gz
135-
```
136-
and then unpack with
137-
```
138-
tar xfz minisat-2.2.1.tar.gz
139-
mv minisat minisat-2.2.1
140-
cd minisat-2.2.1
141-
patch -p1 < ../scripts/minisat-2.2.1-patch
130+
git clone https://github.com/diffblue/cbmc cbmc-git
142131
```
143-
The patch removes the dependency on zlib and prevents a problem with a
144-
header file that is often unavailable on Windows.
145-
1. To compile with Cygwin, install the mingw compilers, and adjust
146-
the second line of config.inc to say
147-
```
148-
BUILD_ENV = MinGW
149-
```
150-
2. To compile with Visual Studio, make sure you have at least Visual
151-
Studio version 12 (2013), and adjust the second line of config.inc to say
132+
3. Depending on your choice of compiler:
133+
1. To compile with Visual Studio, change the second line of `src/config.inc`
134+
to
152135
```
153136
BUILD_ENV = MSVC
154137
```
155-
Open the Visual Studio Command prompt, and then bash.exe -login from
156-
Cygwin from in there.
157-
3. Type cd src; make - that should do it.
138+
Open the Developer Command Prompt for Visual Studio, then start the
139+
Cygwin shell with
140+
```
141+
bash.exe -login
142+
```
143+
2. To compile with MinGW, use Cygwin setup to install a mingw g++ compiler
144+
package, i.e. one of `mingw{32,64}-{x86_64,i686}-gcc-g++`. You may also
145+
have to adjust the section in `src/common` that defines `CC` and `CXX`
146+
for BUILD_ENV = Cygwin.
147+
Then start the Cygwin shell.
148+
4. In the Cygwin shell, type
149+
```
150+
cd cbmc-git/src
151+
make DOWNLOADER=wget minisat2-download
152+
make
153+
```
158154
159155
(Optional) A Visual Studio project file can be generated with the script
160156
"generate_vcxproj" that is in the subdirectory "scripts". The project file is

src/Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ clean: $(patsubst %, %_clean, $(DIRS))
6363
$(patsubst %, %_clean, $(DIRS)):
6464
$(MAKE) $(MAKEARGS) -C $(patsubst %_clean, %, $@) clean ; \
6565

66-
# minisat 2 download, for your convenience
66+
# minisat2 and glucose download, for your convenience
67+
68+
DOWNLOADER = lwp-download
6769

6870
minisat2-download:
6971
@echo "Downloading Minisat 2.2.1"
70-
@lwp-download http://ftp.debian.org/debian/pool/main/m/minisat2/minisat2_2.2.1.orig.tar.gz
72+
@$(DOWNLOADER) http://ftp.debian.org/debian/pool/main/m/minisat2/minisat2_2.2.1.orig.tar.gz
7173
@tar xfz minisat2_2.2.1.orig.tar.gz
7274
@rm -Rf ../minisat-2.2.1
7375
@mv minisat2-2.2.1 ../minisat-2.2.1
@@ -76,7 +78,7 @@ minisat2-download:
7678

7779
glucose-download:
7880
@echo "Downloading glucose-syrup"
79-
@lwp-download http://www.labri.fr/perso/lsimon/downloads/softwares/glucose-syrup.tgz
81+
@$(DOWNLOADER) http://www.labri.fr/perso/lsimon/downloads/softwares/glucose-syrup.tgz
8082
@tar xfz glucose-syrup.tgz
8183
@rm -Rf ../glucose-syrup
8284
@mv glucose-syrup ../

src/common

+5-3
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,19 @@ else ifeq ($(BUILD_ENV_),Cygwin)
101101
CXXFLAGS ?= -Wall -O2
102102
CP_CFLAGS = -MMD -MP
103103
CP_CXXFLAGS += -MMD -MP -std=c++11 -U__STRICT_ANSI__
104+
# Cygwin-g++ has problems with statically linking exception code.
105+
# If linking fails, remove -static.
104106
LINKFLAGS = -static -std=c++11
105107
LINKLIB = ar rcT $@ $^
106-
LINKBIN = $(CXX) $(LINKFLAGS) -o $@ -Wl,--start-group $^ -Wl,--end-group $(LIBS) -static
108+
LINKBIN = $(CXX) $(LINKFLAGS) -o $@ -Wl,--start-group $^ -Wl,--end-group $(LIBS)
107109
LINKNATIVE = $(HOSTCXX) -std=c++11 -o $@ $^ -static
108110
ifeq ($(origin CC),default)
109111
#CC = gcc
110-
CC = i686-w64-mingw32-gcc
112+
CC = x86_64-w64-mingw32-gcc
111113
endif
112114
ifeq ($(origin CXX),default)
113115
#CXX = g++
114-
CXX = i686-w64-mingw32-g++
116+
CXX = x86_64-w64-mingw32-g++
115117
endif
116118
ifeq ($(origin YACC),default)
117119
YACC = bison -y

0 commit comments

Comments
 (0)