aboutsummaryrefslogtreecommitdiff
path: root/INSTALL
blob: 38b51b44da3ac6d441fda0722f73e2fdb6f47660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
Setup
=====

Setting Scripts
---------------

The "driver" scripts that you will be invoking are cl-NN, lib-NN, and link-NN,
where NN is the Visual Studio version (e.g., 11, 12, 14, etc). There are also
the "configuration" scripts, msvc-NN, which provide the Visual Studio/SDK
location and configuration (in a way similar to vcvars32.bat). There is also a
bunch of other helper scripts that you will not need to modify or invoke
directly.

All of these scripts should reside in the same directory. In particular, you
cannot copy, say, cl-NN to /usr/local/bin/ while leaving the rest in some
other directory -- this will not work. What you can do, however, is create
symlinks to the driver scripts in /usr/local/bin/ -- this will work.

If you only need to make the scripts usable by a single user, then the easiest
approach is to add the script's directory to your PATH in, say, .bashrc, for
example:

export PATH=$HOME/msvc-linux:$PATH

Alternatively, if you have something like ~/bin/ that is already in PATH, then
you can simply add symlinks to the scripts.


Install Wine
------------

You need 1.7.55 or later. Previous versions are known not to work with Visual
Studio 14.

For Ubuntu:

# add-apt-repository ppa:ubuntu-wine/ppa
# apt-get update
# apt-get install --no-install-recommends winbind
# apt-get install wine1.7 wine-mono4.5.6 wine-gecko2.40


Configure Wine
--------------

$ winecfg

If it suggests installing some stuff, ignore it. Change the platform to
Windows 7 (later version will probably also work).


Prepare to Copy Visual Studio
-----------------------------

Note that below we assume that you have installed Visual Studio in the default
location.

Mount the VM disk (make sure it is not running) where you installed Visual
Studio. First get the second partition offset (<O>) and sector size (normally
512, as below).

# fdisk -lu .../windows-7.img

Then mount via the loopback device:

# losetup -o $((512*<O>)) /dev/loop0 ./windows-7.img
# mount -o ro /dev/loop0 /mnt

When finished copying Visual Studio, unmount and delete the loopback:

# umount /mnt
# losetup -d /dev/loop0


Copy and Setup Visual Studio 11
-------------------------------

$ mkdir -p ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 11.0"
$ cp -r "/mnt/Program Files (x86)/Microsoft Visual Studio 11.0/VC" \
  ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 11.0/"
$ cp "/mnt/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/mspdb110.dll" \
  ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/"

$ mkdir -p ".wine/drive_c/Program Files (x86)/Windows Kits"
$ cp -r "/mnt/Program Files (x86)/Windows Kits/8.0" \
  ".wine/drive_c/Program Files (x86)/Windows Kits/"

Run the VC11 redistributable DLLs installer for x86 from .../VC/redist/1033/.

Add override for msvcr110.dll: run winecfg, select the "Libraries" tab, then
enter the DLL name and "Add".


Copy and Setup Visual Studio 12
-------------------------------

$ mkdir -p ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 12.0"
$ cp -r "/mnt/Program Files (x86)/Microsoft Visual Studio 12.0/VC" \
  ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 12.0/"

$ mkdir -p ".wine/drive_c/Program Files (x86)/Windows Kits"
$ cp -r "/mnt/Program Files (x86)/Windows Kits/8.1" \
  ".wine/drive_c/Program Files (x86)/Windows Kits/"

Run the VC12 redistributable DLLs installer for x86 from .../VC/redist/1033/.

Add override for msvcr120.dll: run winecfg, select the "Libraries" tab, then
enter the DLL name and "Add".


Copy and Setup Visual Studio 14
-------------------------------

Note: 14 Update 2 requires Wine 1.9.8 or later (bug #34851).
Note: if using 14 Update 2, then use the *-14u2 driver scripts.

$ mkdir -p ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 14.0"
$ cp -r "/mnt/Program Files (x86)/Microsoft Visual Studio 14.0/VC" \
  ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 14.0/"
$ cp "/mnt/Program Files (x86)/Microsoft Visual Studio 14.0/VC/redist/x86/Microsoft.VC140.CRT/msvcp140.dll" \
  ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/"

Remove Microsoft's "experience improvement data uploade" which crashes:

$ rm ".wine/drive_c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/vctip.exe"

$ mkdir -p ".wine/drive_c/Program Files (x86)/Windows Kits"
$ cp -r "/mnt/Program Files (x86)/Windows Kits/8.1" \
  ".wine/drive_c/Program Files (x86)/Windows Kits/"
$ cp -r "/mnt/Program Files (x86)/Windows Kits/10" \
  ".wine/drive_c/Program Files (x86)/Windows Kits/"

Installing via the redistributable DLLs still does not work as of Wine 1.7.55.
Instead, we have to manually copy a bunch of DLLs from /mnt/Windows/SysWoW64/
to VC/bin/ and add Wine overrides (run winecfg, select the "Libraries" tab,
then enter the DLL name and "Add").

To discover the list of DLLs, run cl-14 to compile and link and executable
(see Test below): any DLL that causes an error needs an override.

For Wine 1.7.55 the list is:

  api-ms-win-crt-runtime-l1-1-0.dll
  ucrtbase.dll
  api-ms-win-crt-locale-l1-1-0.dll
  api-ms-win-crt-heap-l1-1-0.dll
  vcruntime140.dll
  api-ms-win-crt-stdio-l1-1-0.dll
  api-ms-win-crt-conio-l1-1-0.dll


Test
----

cl-NN /EHsc /TP hello-world.cxx
./hello-world.exe


Usage
=====

To suppress Wine debug messages (especially advisable if running executables
built with more recent Visual Studio versions) you may want to add the
following line to your .bashrc or similar:

export WINEDEBUG=fixme-all

Certain executions of the cl compiler (e.g., /EP /showIncludes) are very
slow unless wineserver is started and a special voodoo dance is performed:

# Kill existing Wine processes if any.
#
$ pkill wineserver
$ pkill .exe

# Verify no Wine processes are running.
#
$ pgrep wineserver
$ pgrep .exe

# Prepare test file.
#
cat > test.cpp
#include <iostream>
^D

# Get time without wineserver.
#
$ time cl-NN /EP /showIncludes test.cpp >/dev/null

# Start wineserver.
#
$ wineserver -p
$ pgrep wineserver

# The voodoo part: the first execution after starting wineserver will
# hang, but all subsequent ones should be much faster.
#
$ cl-NN /EP /showIncludes test.cpp >/dev/null
^C

# Get time with wineserver.
#
$ time cl-NN /EP /showIncludes test.cpp >/dev/null