Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 820 lines (647 sloc) 39.329 kb
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
1 How to Build Erlang/OTP on Windows
2 ==================================
3
4 Introduction
5 ------------
6
7 This file describes how to build the Erlang emulator and the OTP
8 libraries on Windows. The instructions apply to versions of Windows
9 supporting the Cygwin emulated gnuish environment for Windows. We've
10 built on the following platforms: Windows 2000 Professional, Windows
11 2003 server, Windows XP Home/Professional, and Windows Vista. Any
12 Windows95'ish platform will surely get you into trouble, what I'm not
13 sure of, but it certainly will...
14
15 The procedure described uses Cygwin as a build environment, you run
16 the bash shell in Cygwin and uses gnu make/configure/autoconf etc to
17 do the build. The emulator C-source code is, however, mostly compiled
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
18 with Microsoft Visual C++™, producing a native Windows binary. This
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
19 is the same procedure as we use to build the pre-built binaries. The
20 fact that we use VC++ and not gcc is explained further in the FAQ
21 section.
22
23 I describe the build procedure to make it possible for open source
24 customers to build the emulator, given that they have the needed
25 tools. The binary Windows releases is still a preferred alternative if
26 one does not have Microsoft's development tools and/or don't want to
27 install Cygwin.
28
29 To use Cygwin, one needs basic experience from a Unix environment, if
30 one does not know how to set environment variables, run programs etc
31 in a Unix environment, one will be quite lost in the Cygwin
32 ditto. I can unfortunately not teach all the world how to use
33 Cygwin and bash, neither how to install Cygwin nor perform basic tasks
34 on a computer. Please refer to other documentation on the net for
35 help, or use the binary release instead if you have problems using the
36 tools.
37
38 However, if you feel comfortable with the environment and build
39 system, and have all the necessary tools, you have a great opportunity
40 to make the Erlang/OTP distribution for Windows better. Please submit
4c3aebe @rickard-green OTP-8457 Minor documentation fixes. Mainly anchor adjustments.
authored
41 any suggestions and patches to the appropriate [mailing lists] [1] to let
42 them find their way into the next version of Erlang. If making changes
43 to the build system (like makefiles etc) please bear in mind that the
44 same makefiles are used on Unix/VxWorks/OSEDelta, so that your changes
45 don't break other platforms. That of course goes for C-code too, system
46 specific code resides in the `$ERL_TOP/erts/emulator/sys/win32` and
47 `$ERL_TOP/erts/etc/win32` directories mostly. The
48 `$ERL_TOP/erts/emulator/beam directory` is for common code.
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
49
50 Before the R9C release of Erlang/OTP, the Windows release was built
51 partly on a Unix (Solaris) box and partly on a Windows box, using Perl
52 hacks to communicate and sync between the two machines. R9C was the
53 first release ever built solely on Windows, where no Unix machine is
54 needed at all. Now we've used this build procedure for a couple of
55 releases, and it has worked fine for us. Still, there might be all
56 sorts of troubles on different machines and with different
57 setups. I'll try to give hints wherever I've encountered difficulties,
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
58 but please share your experiences by using the [erlang-questions] [1]
4c3aebe @rickard-green OTP-8457 Minor documentation fixes. Mainly anchor adjustments.
authored
59 mailing list. I cannot of course help everyone with all
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
60 their problems, please try to solve the problems and submit
61 solutions/workarounds. Remember, it's all about sharing, not about
62 demanding...
63
64 Lets go then, I'll start with a little FAQ, based on in house questions
65 and misunderstandings.
66
67
68 Frequently Asked Questions
69 --------------------------
70
71 * Q: So, now I can build Erlang using GCC on Windows?
72
73 A: No, unfortunately not. You'll need Microsoft's Visual C++ still, a
74 Bourne-shell script (cc.sh) wraps the Visual C++ compiler and runs it
75 from within the Cygwin environment. All other tools needed to build
76 Erlang are free-ware/open source, but not the C compiler.
77
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
78 * Q: Why haven't you got rid of VC++ then, you \*\*\*\*\*\*?
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
79
80 A: Well, partly because it's a good compiler - really! Actually it's
81 been possible in late R11-releases to build using mingw instead of
82 visual C++ (you might see the remnants of that in some scripts and
83 directories). Unfortunately the development of the SMP version for
84 Windows broke the mingw build and we chose to focus on the VC++ build
85 as the performance has been much better in the VC++ versions. The
86 mingw build will be back, but as long as VC++ gives better
87 performance, the commercial build will be a VC++ one.
88
89 * Q: OK, VC++ you need, but now you've started to demand a very recent
90 (and expensive) version of Visual studio, not the old and stable VC++
91 6.0 that was used in earlier versions. Why?
92
93 A: The SMP version of Erlang needs features in the Visual Studio 2005.
94 Can't live without them. Besides the new compiler gives the Erlang
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
95 emulator a ~40% performance boost(!). Alternatively you can build Erlang
96 successfully using the free (proprietary) Visual Studio 2008 Express
97 edition C++ compiler.
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
98
99 * Q: Can/will I build a Cygwin binary with the procedure you describe?
100
101 A: No, the result will be a pure Windows binary, and as far as I know,
102 it's not possible to make a Cygwin binary yet. That is of course
103 something desirable, but there are still some problems with the
104 dynamic linking (dynamic Erlang driver loading) as well as the TCP/IP
105 emulation in Cygwin, which, I'm sure of, will improve, but still has
106 some problems. Fixing those problems might be easy or might be hard.
107 I suggest you try yourself and share your experience. No one would be
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
108 happier if a simple `./configure && make` would produce a fully fledged
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
109 Cygwin binary. Ericsson does however not pay me to do a Cygwin port, so
110 such a port would have to happen in spare time, which is a limited
111 resource...
112
113 * Q: Hah, I saw you, you used GCC even though you said you didn't!
114
115 A: OK, I admit, one of the files is compiled using Cygwin's GCC and
116 the resulting object code is then converted to MS VC++ compatible coff
117 using a small C hack. It's because that particular file, `beam_emu.c`
118 benefits immensely from being able to use the GCC labels-as-values
119 extension, which boosts emulator performance by up to 50%. That does
120 unfortunately not (yet) mean that all of OTP could be compiled using
121 GCC, that particular source code does not do anything system specific
122 and actually is adopted to the fact that GCC is used to compile it on
123 Windows.
124
125 * Q: So now there's a MS VC++ project file somewhere and I can build OTP
126 using the nifty VC++ GUI?
127
128 A: No, never. The hassle of keeping the project files up to date and
129 do all the steps that constitute an OTP build from within the VC++ GUI
130 is simply not worth it, maybe even impossible. A VC++ project
131 file for Erlang/OTP will never happen, at least I will never make
132 one. Clicking around in super-multi-tab'd dialogs to add a file or
133 compiler option when it's so much easier in a makefile is simply not
134 my style.
135
136 * Q: So how does it all work then?
137
138 A: Cygwin is the environment, which closely resembles the environments
139 found on any Unix machine. It's almost like you had a virtual Unix
140 machine inside Windows. Configure, given certain parameters, then
141 creates makefiles that are used by the Cygwin gnu-make to built the
142 system. Most of the actual compilers etc are not, however, Cygwin
143 tools, so I've written a couple of wrappers (Bourne-shell scripts),
144 which reside in `$ERL_TOP/etc/win32/cygwin_tools` and they all do
145 conversion of parameters and switches common in the Unix environment
146 to fit the native Windows tools. Most notable is of course the paths,
147 which in Cygwin are Unix-like paths with "forward slashes" (/) and no
148 drive letters, the Cygwin specific command `cygpath` is used for most
149 of the path conversions. Luckily most compilers accept forward slashes
150 instead of backslashes as path separators, one still have to get the
151 drive letters etc right, though. The wrapper scripts are not general
152 in the sense that, for example, cc.sh would understand and translates
153 every possible gcc option and passes correct options to cl.exe. The
154 principle is that the scripts are powerful enough to allow building of
155 Erlang/OTP, no more, no less. They might need extensions to cope with
156 changes during the development of Erlang, that's one of the reasons I
157 made them into shell-scripts and not Perl-scripts, I believe they are
158 easier to understand and change that way. I might be wrong though,
159 cause another reason I didn't write them in Perl is because I've never
160 liked Perl and my Perl code is no pleasant reading...
161
162 In `$ERL_TOP`, there is a script called `otp_build`, that script handles
163 the hassle of giving all the right parameters to `configure`/`make` and
164 also helps you set up the correct environment variables to work with
165 the Erlang source under Cygwin.
166
167 * Q: You use and need Cygwin, but then you haven't taken the time to
168 port Erlang to the Cygwin environment but instead focus on your
169 commercial release, is that really ethical?
170
171 A: No, not really, but see this as a step in the right direction. I'm
172 aiming at GCC compiled emulators and a Cygwin version, but I really
173 need to do other things as well... In time, but don't hold your
174 breath...
175
176 * Q: Can I build something that looks exactly as the commercial release?
177
178 A: Yes, we use the exactly same build procedure.
179
180 * Q: Which version of Cygwin and other tools do you use then?
181
182 A: For Cygwin we try to use the latest releases available when
183 building. What versions you use shouldn't really matter, I try to
184 include workarounds for the bugs I've found in different Cygwin
185 releases, please help me to add workarounds for new Cygwin-related
186 bugs as soon as you encounter them. Also please do submit bug reports
150f681 @bufflig ** Empty commit message **
bufflig authored
187 to the appropriate Cygwin developers. The Cygwin GCC we used for %OTP-REL%
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
188 was version 3.4.4. We used VC++ 8.0 (i.e. Visual studio 2005 SP1),
189 Sun's JDK 1.5.0\_17, NSIS 2.37, and Win32 OpenSSL 0.9.8e. Please read
190 the next section for details on what you need.
191
192 * Q: Can you help me setup X in Cygwin?
193
194 A: No, unfortunately I haven't got time to help with Cygwin related
195 user problems, please read Cygwin related web sites, newsgroups and
196 mailing lists.
197
198 * Q: Why is the instruction so long? Is it really that complicated?
199
200 A: Partly it's long because I babble too much, partly because I've
201 described as much as I could about the installation of the needed
202 tools. Once the tools are installed, building is quite easy. I also
203 have tried to make this instruction understandable for people with
204 limited Unix experience. Cygwin is a whole new environment to some
205 Windows users, why careful explanation of environment variables etc
206 seemed to be in place. The short story, for the experienced and
207 impatient is:
208
209 * Get and install complete Cygwin (latest)
210
211 * (Buy and) Install Microsoft Visual studio 2005 and SP1 (or higher)
212
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
213 * Alternatively install the free MS Visual Studio 2008 Express [msvc++]
214 and the Windows SDK [32bit-SDK] or [64bit-SDK] depending on the Windows
215 platform you are running.
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
216
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
217 * Get and install Sun's JDK 1.4.2
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
218
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
219 * Get and install NSIS 2.01 or higher (up to 2.46 tried and working)
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
220
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
221 * Get and install OpenSSL 0.9.7c or higher (up to 1.0.0a tried & working)
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
222
223 * Get the Erlang source distribution (from
224 <http://www.erlang.org/download.html>) and unpack with Cygwin's `tar`.
225
226 * Set `ERL_TOP` to where you unpacked the source distribution
227
228 * `$ cd $ERL_TOP`
229
230 * Get (from <http://www.erlang.org/download/tcltk85_win32_bin.tar.gz>)
231 and unpack the prebuilt TCL/TK binaries for windows with cygwin tar,
232 standing in `$ERL_TOP`
233
234 * Modify PATH and other environment variables so that all these tools
235 are runnable from a bash shell. Still standing in `$ERL_TOP`, issue
236 the following commands:
237
238 $ eval `./otp_build env_win32`
239 $ ./otp_build autoconf
240 $ ./otp_build configure
241 $ ./otp_build boot -a
242 $ ./otp_build release -a
243 $ ./otp_build installer_win32
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
244 $ release/win32/otp_win32_%OTP-REL% /S
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
245
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
246 Voila! `Start->Programs->Erlang OTP %OTP-REL%->Erlang` starts the Erlang
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
247 Windows shell.
248
249
250 Tools you Need and Their Environment
251 ------------------------------------
252
253 You need some tools to be able to build Erlang/OTP on Windows. Most
254 notably you'll need Cygwin and Microsoft VC++, but you also might want
255 a Java compiler, the NSIS install system and OpenSSL. Only VC++ costs
256 money, but then again it costs a lot of money, I know...
257 Well' here's the list:
258
259 * Cygwin, the very latest is usually best. Get all the development
260 tools and of course all the basic ditto. In fact getting the complete
261 package might be a good idea, as you'll start to love Cygwin after a
262 while if you're accustomed to Unix. Make sure to get jar and also make
263 sure *not* to install a Cygwin'ish Java... The Cygwin jar command is
264 used but Sun's Java compiler and virtual machine...
265
266 URL: <http://www.cygwin.com>
267
268 Get the installer from the web site and use that to install
269 Cygwin. Be sure to have fair privileges. If you're on a NT domain you
270 should consider running `mkpasswd -d` and `mkgroup -d` after the
271 installation to get the user databases correct. See their respective
272 manual pages.
273
274 When you start you first bash shell, you will get an awful prompt. You
275 might also have a `PATH` environment variable that contains backslashes
276 and such. Edit `$HOME/.profile` and `$HOME/.bashrc` to set fair prompts
277 and set a correct PATH. Also do a `export SHELL` in `.profile`. For some
278 non-obvious reason the environment variable `$SHELL` is not exported in
279 bash. Also note that `.profile` is run at login time and `.bashrc` when
280 sub shells are created. You'll need to explicitly source `.bashrc` from
281 `.profile` if you want the commands there to be run at login time (like
282 setting up aliases, shell functions and the like). I personally
283 usually do like this at the end of `.profile`:
284
285 ENV=$HOME/.bashrc
286 export ENV
287 . $ENV
288
289 You might also, if you're a hard core type of person at least, want to
290 setup X-windows (XFree86), that might be as easy as running startx
291 from the command prompt and it might be much harder. Use Google to
292 find help...
293
294 If you don't use X-windows, you might want to setup the Windows
295 console window by selecting properties in the console system menu
296 (upper left corner of the window, the Cygwin icon in the title
297 bar). Especially setting a larger screen buffer size (lines) is useful
298 as it gets you a scrollbar so you can see whatever error messages
299 that might appear...
300
301 If you want to use (t)csh instead of bash you're on your own, I
302 haven't tried and know of no one that has. I expect
303 that you use bash in all shell examples.
304
305 * Microsoft Visual Studio 2005 SP1. Please don't skip the service
306 pack! The installer might update your environment so that you can run
307 the `cl` command from the bash prompt, then again it might
308 not... There is always a BAT file in VC\Bin under the installation
309 directory (default `C:\Program Files\Microsoft Visual Studio 8`) called
310 `VCVARS32.BAT`. Either add the environment settings in that file to the
311 global environment settings in Windows or add the corresponding BASH
312 environment settings to your `.profile`/`.bashrc`. For example, in my case
313 I could add the following to `.profile`
314
315 #Visual C++ Root directory as Cygwin style pathname
316 VCROOT=/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio 8
317
318 # Visual C++ Root directory as Windows style pathname
319 WIN_VCROOT="C:\\Program Files\\Microsoft Visual Studio 8"
320
321 # The PATH variable should be Cygwin'ish
322 PATH=$VCROOT/Common7/IDE:$VCROOT/VC/BIN:$VCROOT/Common7/Tools:\
323 $VCROOT/Common7/Tools/bin:$VCROOT/VC/PlatformSDK/bin:$VCROOT/SDK/v2.0/bin:\
324 $VCROOT/VC/VCPackages:$PATH
325
326 # Lib and INCLUDE should be Windows'ish
327 # Note that semicolon (;) is used to separate Windows style paths but
328 # colon (:) to separate Cygwin ditto!
329
330 LIBPATH=$WIN_VCROOT\\VC\\ATLMFC\\LIB
331
332 LIB=$WIN_VCROOT\\VC\\ATLMFC\\LIB\;$WIN_VCROOT\\VC\\LIB\;\
333 $WIN_VCROOT\\VC\\PlatformSDK\\lib\;$WIN_VCROOT\\SDK\\v2.0\\lib
334
335 INCLUDE=$WIN_VCROOT\\VC\\ATLMFC\\INCLUDE\;$WIN_VCROOT\\VC\\INCLUDE\;\
336 $WIN_VCROOT\\VC\\PlatformSDK\\include
337
338 export PATH LIB INCLUDE
339
340 Make a simple hello world and try to compile it with the `cl` command
341 from within bash. If that does not work, your environment needs
342 fixing. Also remember to fix up the PATH environment, especially old
343 Erlang installations might have inserted quoted paths that Cygwin does
344 not understand. Remove or correct such paths. There should be no
345 backslashes in your path environment variable in Cygwin bash, but LIB
346 and INCLUDE should contain Windows style paths with semicolon,
347 drive letters and backslashes.
348
349 If you wish to use Visual Studio 2008, a couple things need to be tweaked,
350 namely the fact that some of the SDK stuff is installed in (by default)
351 `C:\Program Files\Microsoft SDKs\v6.0A` . Just ensure that that
352 `C:\Program Files\Microsoft SDKs\v6.0A\Lib` is in `LIB` and
353 `C:\Program Files\Microsoft SDKs\v6.0A\Include` is in `INCLUDE`. A symptom
354 of not doing this is errors about finding kernel32.lib and windows.h.
355
356 Additionally, if you encounter errors about mc.exe not being found, you must
357 install the entire Windows SDK (the partial SDK included in visual studio
358 apparently does not include it). After installing it you'll want to add
359 something like: `/c/cygdrive/Program\ Files/Microsoft\ SDKs/v7.0/bin` to
360 your `PATH` to allow the environment to find mc.exe. The next Visual Studio
361 (2010) is expected to include this tool.
362
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
363 Alternatively install the free MS Visual Studio 2008 Express [msvc++] and
364 the Windows SDK [32bit-SDK] or [64bit-SDK] depending on the Windows
365 platform you are running, which includes the missing mc.exe message
366 compiler.
367
368 [msvc++]: http://download.microsoft.com/download/E/8/E/E8EEB394-7F42-4963-A2D8-29559B738298/VS2008ExpressWithSP1ENUX1504728.iso
369 [32bit-SDK]: http://download.microsoft.com/download/2/E/9/2E911956-F90F-4BFB-8231-E292A7B6F287/GRMSDK_EN_DVD.iso
370 [64bit-SDK]: http://download.microsoft.com/download/2/E/9/2E911956-F90F-4BFB-8231-E292A7B6F287/GRMSDKX_EN_DVD.iso
371
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
372 * Sun's Java JDK 1.5.0 or higher. Our Java code (jinterface, ic) is
373 written for JDK 1.5.0. Get it for Windows and install it, the JRE is
374 not enough. If you don't care about Java, you can skip this step, the
375 result will be that jinterface is not built.
376
377 URL: <http://java.sun.com>
378
379 Add javac *LAST* to your path environment in bash, in my case this means:
380
381 PATH="$PATH:/cygdrive/c/Program Files/Java/jdk1.5.0_17/bin"
382
383 No `CLASSPATH` or anything is needed. Type `javac` at the bash prompt
384 and you should get a list of available Java options. Make sure by
385 typing `which java` that you use the Java you installed. Note however that
386 Cygwin's `jar.exe` is used, that's why the JDK bin-directory should be
387 added last in the `PATH`.
388
389 * Nullsoft NSIS installer system. You need this to build the self
390 installing package. It's a free open source installer that's much
391 nicer to use than the commercial Wise and Install shield
392 installers. This is the installer we use for commercial releases as
393 well from R9C an on.
394
395 URL: <http://www.nullsoft.com/free/nsis>
396
397 Install the lot, especially the modern user interface components, as
398 it's definitely needed. Put `makensis` in your path, in my case:
399
400 PATH=/cygdrive/c/Program\ Files/NSIS:$PATH
401
402 type makensis at the bash prompt and you should get a list of options
403 if everything is OK.
404
405 * OpenSSL for Windows. This is if you want the SSL and crypto
406 applications to compile (and run). Go to <http://www.openssl.org>, click
407 on the `Related` link and then on the `Binaries` link (upper right
408 corner of the page last time I looked), you can then reach the
409 "Shining Lights Productions" Web site for Windows binaries
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
410 distributions. Get the latest 32-bit installer, or use 0.9.7c if you get
411 trouble with the latest, and install to C:\OpenSSL which is where the
412 Makefiles are expecting to find it. It's a nifty installer. The rest should
413 be handled by `configure`, you needn't put anything in the path or anything.
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
414
415 If you want to build openssl for windows yourself (which might be
416 possible, as you wouldn't be reading this if you weren't a
417 compile-it-yourself person), you either have to put the resulting
418 DLL's in your path or in the windows system directory and either
419 specify where you put the includes etc with the configure-parameter
420 `--with-ssl=<cygwin path to the root>` or put your installation directly
421 under `c:\OpenSSL`. The directory structure under the installation root
422 for OpenSSL is expected to be one with subdirectories named `include`,
423 `bin` and `lib`, possibly with a `VC` subdirectory of `lib` containing
424 the actual `.lib` files. Note that the cygwin distributed OpenSSL cannot be
425 used, it results in cygwin depending binaries and it has unix style
426 archives (`.a`, not `.lib`).
427
428 * Building with wxWidgets. Download wxWidgets-2.8.9 or higher patch
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
429 release (2.9.\* is a developer release which currently does not work
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
430 with wxErlang).
431
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
432 Install or unpack it to `DRIVE:/PATH/cygwin/opt/local/pgm`.
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
433 Open from explorer (i.e. by double clicking the file)
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
434 `C:\cygwin\opt\local\pgm\wxMSW-2.8.11\build\msw\wx.dsw`
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
435 In Microsoft Visual Studio, click File/Open/File, locate and
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
436 open: `C:\cygwin\opt\local\pgm\wxMSW-2.8.11\include\wx\msw\setup.h`
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
437 enable `wxUSE_GLCANVAS`, `wxUSE_POSTSCRIPT` and `wxUSE_GRAPHICS_CONTEXT`
438 Build it by clicking Build/Batch Build and select all unicode release
439 (and unicode debug) packages.
440
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
441 Open `C:\cygwin\opt\local\pgm\wxMSW-2.8.11\contrib/build/stc/stc.dsw`
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
442 and batch build all unicode packages.
443
8e8061c @dch Doc update to latest dependencies & how to compile with free VS2008 E…
dch authored
444 If you are using Visual C++ 9.0 or higher (Visual Studio 2008 onwards) you
445 will also need to convert and re-create the project dependencies in the new
446 .sln "Solution" format.
447
448 * Open VSC++ & the project `wxMSW-2.8.11\build\msw\wx.dsw`, accepting the
449 automatic conversion to the newer VC++ format and save as
450 `\wxMSW-2.8.11\build\msw\wx.sln`
451
452 * right-click on the project, and set up the project dependencies for
453 `wx.dsw` to achieve the below build order
454
455 jpeg, png, tiff, zlib, regex, expat, base, net, odbc, core,
456 gl, html, media, qa, adv, dbgrid, xrc, aui, richtext, xml
457
458 Build all unicode release (and unicode debug) packages either from the
459 GUI or alternatively launch a new prompt from somewhere like Start ->
460 Programs -> Microsoft Visual C++ -> Visual Studio Tools -> VS2008 Cmd Prompt
461 and cd to where you unpacked wxMSW
462
463 pushd c:\wxMSW*\build\msw
464 vcbuild /useenv /platform:Win32 /M4 wx.sln "Unicode Release|Win32"
465 vcbuild /useenv /platform:Win32 /M4 wx.sln "Unicode Debug|Win32"
466
467 Open VSC++ & convert `C:\wxMSW-2.8.11\contrib\build\stc\stc.dsw` to
468 `C:\wxMSW-2.8.11\contrib\build\stc\stc.sln`
469
470 * build the unicode release (and unicode debug) packages from the GUI or
471 alternatively open a VS2008 Cmd Prompt and cd to where you unpacked wxMSW
472
473 pushd c:\wxMSW*\contrib\build\stc
474 vcbuild /useenv /platform:Win32 /M4 stc.sln "Unicode Release|Win32"
475 vcbuild /useenv /platform:Win32 /M4 stc.sln "Unicode Debug|Win32"
476
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
477 * The Erlang source distribution (from <http://www.erlang.org/download.html>).
478 The same as for Unix platforms. Preferably use tar from within Cygwin to
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
479 unpack the source tar.gz (`tar zxf otp_src_%OTP-REL%.tar.gz`).
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
480
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
481 set the environment `ERL_TOP` to point to the root directory of the
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
482 source distribution. Let's say I stood in `$HOME/src` and unpacked
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
483 `otp_src_%OTP-REL%.tar.gz`, I then add the following to `.profile`:
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
484
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
485 ERL_TOP=$HOME/src/otp_src_%OTP-REL%
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
486 export $ERL_TOP
487
488 * The TCL/TK binaries. You could compile Tcl/Tk for windows yourself,
489 but you can get a stripped down version from our website which is
490 suitable to include in the final binary package. If you want to supply
491 tcl/tk yourself, read the instructions about how the tcl/tk tar file
492 used in the build is constructed under `$ERL_TOP/lib/gs/tcl`. The easy
493 way is to download <http://www.erlang.org/download/tcltk85_win32_bin.tar.gz>
494 and unpack it standing in the `$ERL_TOP` directory. This will create the
495 file `win32.tar.gz` in `$ERL_TOP/lib/gs/tcl/binaries`.
496
497 One last alternative is to create a file named `SKIP` in the
498 `$ERL_TOP/lib/gs/` after configure is run, but that will give you an
499 erlang system without gs (which might be okay as you probably will use
500 wx anyway).
501
502 The Shell Environment
503 ---------------------
504
505 So, if you have followed the instructions above, when you start a bash
506 shell, you should have an INCLUDE environment with a Windows style
507 path, a LIB environment variable also in Windows style, and finally a
508 PATH that let's you reach cl, makensis, javac etc from the
509 command prompt (use `which cl` etc to verify from bash).
510
511 You should also have an `ERL_TOP` environment variable that is *Cygwin
512 style*, and points to a directory containing, among other files, the
513 script `otp_build`.
514
515 A final massage of the environment is needed, and that is done by
516 the script `$ERL_TOP/otp_build`. Start bash and do the following, note
517 the "back-ticks" (\`), can be quite hard to get on some keyboards, but
518 pressing the back-tick key followed by the space bar might do it...
519
520 $ cd $ERL_TOP
521 $ eval `./otp_build env_win32`
522
523 If you're unable to produce back-ticks on your keyboard, you can use
524 the ksh variant:
525
526 $ cd $ERL_TOP
527 $ eval $(./otp_build env_win32)
528
529 This should do the final touch to the environment and building should
530 be easy after this. You could run `./otp_build env_win32` without
531 `eval` just to see what it does, and to see that the environment it
532 sets seems OK. The path is cleaned of spaces if possible (using DOS
533 style short names instead), the variables `OVERRIDE_TARGET`, `CC`, `CXX`,
534 `AR` and `RANLIB` are set to their respective wrappers and the directories
535 `$ERL_TOP/erts/etc/win32/cygwin_tools/vc` and
536 `$ERL_TOP/erts/etc/win32/cygwin_tool` are added first in the PATH.
537
538 Try now a `which erlc`. That should result in the erlc wrapper script
539 (which does not have the .sh extension, for reasons best kept
540 untold...). It should reside in `$ERL_TOP/erts/etc/win32/cygwin_tools`.
541 You could also try `which cc.sh`, which `ar.sh` etc.
542
543 Now you're ready to build...
544
545
546 Building and Installing
547 -----------------------
548
549 Now it's assumed that you have executed `` eval `./otp_build env_win32` ``
550 for this particular shell...
551
552 Building is easiest using the `otp_build` script. That script takes care
553 of running configure, bootstrapping etc on Windows in a simple
554 way. The `otp_build` script is the utility we use ourselves to build on
555 different platforms and it therefore contains code for all sorts of
556 platforms. The principle is, however, that for non-Unix platforms, one
557 uses `./otp_build env_<target>` to set up environment and then the
558 script knows how to build on the platform "by itself". You've already
559 run `./otp_build env_win32` in the step above, so now it's mostly like
560 we build on any platform. OK, here are then steps; Assuming you will
561 want to build a full installation executable with NSIS, you can omit
562 `<installation directory>` and the release will be copied to
563 `$ERL_TOP/release/win32`: and there is where the packed self installing
564 executable will reside too.
565
566 $ ./otp_build autoconf # Ignore the warning blob about versions of autoconf
567 $ ./otp_build configure <optional configure options>
568 $ ./otp_build boot -a
569 $ ./otp_build release -a <installation directory>
570 $ ./otp_build installer_win32 <installation directory> # optional
571
572 Now you will have a file called `otp_win32_R12B.exe` in the
573 `<installation directory>`, i.e. `$ERL_TOP/release/win32`.
574
575 Lets get into more detail:
576
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
577 1. `$ ./otp_build autoconf` - This step rebuilds the configure scripts
578 to work correctly in the cygwin environment. In an ideal world, this
579 would not be needed, but alas, we have encountered several
580 incompatibilities between our distributed configure scripts (generated
581 on a Linux platform) and the cygwin environment over the
582 years. Running autoconf on cygwin ensures that the configure scripts
583 are generated in a cygwin-compatible way and that they will work well
584 in the next step.
585
586 2. `$ ./otp_build configure` - This runs the newly generated configure
587 scripts with options making configure behave nicely. The target machine
588 type is plainly `win32`, so a lot of the configure-scripts recognize
589 this awkward target name and behave accordingly. The CC variable also
590 makes the compiler be `cc.sh`, which wraps MSVC++, so all configure
591 tests regarding the C compiler gets to run the right compiler. A lot of
592 the tests are not needed on Windows, but I thought it best to run the
593 whole configure anyway. The only configure option you might want to
594 supply is `--with-ssl`, which might be needed if you have built your
595 own OpenSSL distribution. The Shining Lights distribution should be
596 found automatically by `configure`, if that fails, add a
597 `--with-ssl=<dir>` that specifies the root directory of your OpenSSL
598 installation.
599
600 3. `$ ./otp_build boot -a` - This uses the bootstrap directory (shipped
601 with the source, `$ERL_TOP/bootstrap`) to build a complete OTP
602 system. It first builds an emulator and sets up a minimal OTP system
603 under `$ERL_TOP/bootstrap`, then starts to compile the different OTP
604 compilers to make the `$ERL_TOP/bootstrap` system potent enough to be
605 able to compile all Erlang code in OTP. Then, all Erlang and C code
606 under `$ERL_TOP/lib` is built using the bootstrap system, giving a
607 complete OTP system (although not installed). When this is done, one
608 can run Erlang from within the source tree, just type `$ERL_TOP/bin/erl`
609 and you should have a prompt. If you omit the -a flag, you'll get a
610 smaller system, that might be useful during development. Now
611 exit from Erlang and start making a release of the thing:
612
613 4. `$ ./otp_build release -a` - Builds a commercial release tree from the
614 source tree, default is to put it in `$ERL_TOP/release/win32`, you can
615 give any directory as parameter (Cygwin style), but it doesn't really
616 matter if you're going to build a self extracting installer too. You
617 could of course build release to the final directory and then run
618 `./Install.exe` standing in the directory where the release was put,
619 that will create a fully functional OTP installation. But let's make
620 the nifty installer:
621
622 5. `$ ./otp_build installer_win32` - Create the self extracting installer
623 executable. The executable `otp_win32_%OTP-REL%.exe` will be placed
624 in the top directory of the release created in the previous step. If
625 no release directory is specified, the release is expected to have
626 been built to `$ERL_TOP/release/win32`, which also will be the place
627 where the installer executable will be placed. If you specified some
628 other directory for the release (i.e. `./otp_build release -a
629 /tmp/erl_release`), you're expected to give the same parameter here,
630 (i.e. `./otp_build installer_win32 /tmp/erl_release`). You need to have
631 a full NSIS installation and `makensis.exe` in your path for this to
632 work of course. Once you have created the installer, you can run it to
633 install Erlang/OTP in the regular way, just run the executable and
634 follow the steps in the installation wizard. To get all default settings
635 in the installation without any questions asked, you run the executable
636 with the parameter `/S` (capital S) like in:
637
638 $ cd $ERL_TOP
639 $ release/win32/otp_win32_%OTP-REL% /S
640 ...
641
642 and after a while Erlang/OTP-%OTP-REL% will have been installed in
643 `C:\Program Files\erl%ERTS-VSN%\`, with shortcuts in the menu etc.
644
645 The necessary setup of an Erlang installation is actually done by the
646 program `Install.exe`, which resides in the release top. That program
647 creates `.ini`-files and copies the correct boot scripts. If one has
648 the correct directory tree (like after a `./otp_build release -a`), only
649 the running of `Install.exe` is necessary to get a fully functional
650 OTP. What the self extracting installer adds is (of course) the
651 possibility to distribute the binary easily, together with adding
652 shortcuts to the Windows start menu. There is also some adding of
653 entries in the registry, to associate `.erl` and `.beam` files with
654 Erlang and get nifty icons, but that's not something you'll really need
655 to run Erlang. The registry is also used to store uninstall information,
656 but if one has not used the self extracting installer, one cannot
657 (need not) do any uninstall, one just scratches the release directory
658 and everything is gone. Erlang/OTP does not *need* to put anything
659 in the Windows registry at all, and does not if you don't use the self
660 extracting installer. In other words the installer is pure cosmetics.
661
662 > *NOTE*: Beginning with R9C, the Windows installer does *not* add Erlang
663 > to the system wide path. If one wants to have Erlang in the path, one
664 > has to add it by hand.
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
665
666 Development
667 -----------
668
669 Once the system is built, you might want to change it. Having a test
670 release in some nice directory might be useful, but you also can run
671 Erlang from within the source tree. The target `local_setup`, makes
672 the program `$ERL_TOP/bin/erl.exe` usable and it also uses all the OTP
673 libraries in the source tree.
674
675 If you hack the emulator, you can then build the emulator executable
676 by standing in `$ERL_TOP/erts/emulator` and do a simple
677
678 $ make opt
679
680 Note that you need to have run ``(cd $ERL_TOP && eval `./otp_build env_win32`)``
681 in the particular shell before building anything on Windows. After
682 doing a make opt you can test your result by running `$ERL_TOP/bin/erl`.
683 If you want to copy the result to a release directory (say
684 `/tmp/erl_release`), you do this (still in `$ERL_TOP/erts/emulator`)
685
686 $ make TESTROOT=/tmp/erl_release release
687
688 That will copy the emulator executables.
689
690 To make a debug build of the emulator, you need to recompile both
691 `beam.dll` (the actual runtime system) and `erlexec.dll`. Do like this
692
693 $ cd $ERL_TOP
694 $ rm bin/win32/erlexec.dll
695 $ cd erts/emulator
696 $ make debug
697 $ cd ../etc
698 $ make debug
699
700 and sometimes
701
702 $ cd $ERL_TOP
703 $ make local_setup
704
705 So now when you run `$ERL_TOP/erl.exe`, you should have a debug compiled
706 emulator, which you will see if you do a:
707
708 1> erlang:system_info(system_version).
709
710 in the erlang shell. If the returned string contains `[debug]`, you
711 got a debug compiled emulator.
712
713 To hack the erlang libraries, you simply do a `make opt` in the
714 specific "applications" directory, like:
715
716 $ cd $ERL_TOP/lib/stdlib
717 $ make opt
718
719 or even in the source directory...
720
721 $ cd $ERL_TOP/lib/stdlib/src
722 $ make opt
723
724 Note that you're expected o have a fresh Erlang in your path when
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
725 doing this, preferably the plain %OTP-REL% you have built in the previous
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
726 steps. You could also add `$ERL_TOP/bootstrap/bin` to your `PATH` before
727 rebuilding specific libraries, that would give you a good enough
728 Erlang system to compile any OTP erlang code. Setting up the path
729 correctly is a little bit tricky, you still need to have
730 `$ERL_TOP/erts/etc/win32/cygwin_tools/vc` and
731 `$ERL_TOP/erts/etc/win32/cygwin_tools` *before* the actual emulator
732 in the path. A typical setting of the path for using the bootstrap
733 compiler would be:
734
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
735 $ export PATH=$ERL_TOP/erts/etc/win32/cygwin_tools/vc\
736 :$ERL_TOP/erts/etc/win32/cygwin_tools:$ERL_TOP/bootstrap/bin:$PATH
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
authored
737
738 That should make it possible to rebuild any library without hassle...
739
740 If you want to copy a library (an application) newly built, to a
741 release area, you do like with the emulator:
742
743 $ cd $ERL_TOP/lib/stdlib
744 $ make TESTROOT=/tmp/erlang_release release
745
746 Remember that:
747
748 * Windows specific C-code goes in the `$ERL_TOP/erts/emulator/sys/win32`,
749 `$ERL_TOP/erts/emulator/drivers/win32` or `$ERL_TOP/erts/etc/win32`.
750
751 * Windows specific erlang code should be used conditionally and the
752 host OS tested in *runtime*, the exactly same beam files should be
753 distributed for every platform! So write code like:
754
755 case os:type() of
756 {win32,_} ->
757 do_windows_specific();
758 Other ->
759 do_fallback_or_exit()
760 end,
761
762 That's basically all you need to get going.
763
764 Final Words
765 -----------
766 My hope is that the possibility to build the whole system on Windows
767 will open up for free development on this platform too. There are many
768 things one might want to do better in the Windows version, like the
769 window-style command prompt as well as pure Cygwin porting. Although i
770 realize it's a much larger step to start building on Windows (with all
771 the software you need) than for instance on Linux, I sincerely hope
772 that some of you will make the effort and start submitting Windows
773 friendly patches.
774
775 The first build system for Erlang using Cygwin on Windows was created
776 by Per Bergkvist. I haven't used his build system, but it's rumored to
777 be good. The idea to do this came from his work, so credit is well
778 deserved.
779
780 Of course this would have been completely impossible without the
781 excellent Cygwin package. The guys at Cygnus solutions and Redhat
782 deserves a huge THANKS! as well as all the other people in the free
783 software community who have helped in creating the magnificent
784 software that constitutes Cygwin.
785
786 Good luck and Happy Hacking,
787 Patrik, OTP
788
789 Copyright and License
790 ---------------------
791
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
792 %CopyrightBegin%
793
794 Copyright Ericsson AB 2003-2010. All Rights Reserved.
795
796 The contents of this file are subject to the Erlang Public License,
797 Version 1.1, (the "License"); you may not use this file except in
798 compliance with the License. You should have received a copy of the
799 Erlang Public License along with this software. If not, it can be
800 retrieved online at http://www.erlang.org/.
801
802 Software distributed under the License is distributed on an "AS IS"
803 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
804 the License for the specific language governing rights and limitations
805 under the License.
806
807 %CopyrightEnd%
808
809 Modifying This Document
810 -----------------------
811
812 Before modifying this document you need to have a look at the
813 `$ERL_TOP/README.md.txt` document.
814
4c3aebe @rickard-green OTP-8457 Minor documentation fixes. Mainly anchor adjustments.
authored
815
816
817 [1]: http://www.erlang.org/faq.html "mailing lists"
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
authored
818
819 [?TOC]: true
Something went wrong with that request. Please try again.