Skip to content


Subversion checkout URL

You can clone with
Download ZIP
100644 780 lines (618 sloc) 36.3 KB
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
1 How to Build Erlang/OTP on Windows
2 ==================================
4 Introduction
5 ------------
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...
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
rickard-green authored
18 with Microsoft Visual C++™, producing a native Windows binary. This
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green 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.
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.
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.
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.
rickard-green 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.
rickard-green authored
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
rickard-green authored
58 but please share your experiences by using the [erlang-questions] [1]
4c3aebe @rickard-green OTP-8457 Minor documentation fixes. Mainly anchor adjustments.
rickard-green authored
59 mailing list. I cannot of course help everyone with all
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green 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...
64 Lets go then, I'll start with a little FAQ, based on in house questions
65 and misunderstandings.
68 Frequently Asked Questions
69 --------------------------
71 * Q: So, now I can build Erlang using GCC on Windows?
73 A: No, unfortunately not. You'll need Microsoft's Visual C++ still, a
74 Bourne-shell script ( 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.
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
78 * Q: Why haven't you got rid of VC++ then, you \*\*\*\*\*\*?
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
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.
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?
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
95 emulator a ~40% performance boost(!)
97 * Q: Can/will I build a Cygwin binary with the procedure you describe?
99 A: No, the result will be a pure Windows binary, and as far as I know,
100 it's not possible to make a Cygwin binary yet. That is of course
101 something desirable, but there are still some problems with the
102 dynamic linking (dynamic Erlang driver loading) as well as the TCP/IP
103 emulation in Cygwin, which, I'm sure of, will improve, but still has
104 some problems. Fixing those problems might be easy or might be hard.
105 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
rickard-green authored
106 happier if a simple `./configure && make` would produce a fully fledged
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
107 Cygwin binary. Ericsson does however not pay me to do a Cygwin port, so
108 such a port would have to happen in spare time, which is a limited
109 resource...
111 * Q: Hah, I saw you, you used GCC even though you said you didn't!
113 A: OK, I admit, one of the files is compiled using Cygwin's GCC and
114 the resulting object code is then converted to MS VC++ compatible coff
115 using a small C hack. It's because that particular file, `beam_emu.c`
116 benefits immensely from being able to use the GCC labels-as-values
117 extension, which boosts emulator performance by up to 50%. That does
118 unfortunately not (yet) mean that all of OTP could be compiled using
119 GCC, that particular source code does not do anything system specific
120 and actually is adopted to the fact that GCC is used to compile it on
121 Windows.
123 * Q: So now there's a MS VC++ project file somewhere and I can build OTP
124 using the nifty VC++ GUI?
126 A: No, never. The hassle of keeping the project files up to date and
127 do all the steps that constitute an OTP build from within the VC++ GUI
128 is simply not worth it, maybe even impossible. A VC++ project
129 file for Erlang/OTP will never happen, at least I will never make
130 one. Clicking around in super-multi-tab'd dialogs to add a file or
131 compiler option when it's so much easier in a makefile is simply not
132 my style.
134 * Q: So how does it all work then?
136 A: Cygwin is the environment, which closely resembles the environments
137 found on any Unix machine. It's almost like you had a virtual Unix
138 machine inside Windows. Configure, given certain parameters, then
139 creates makefiles that are used by the Cygwin gnu-make to built the
140 system. Most of the actual compilers etc are not, however, Cygwin
141 tools, so I've written a couple of wrappers (Bourne-shell scripts),
142 which reside in `$ERL_TOP/etc/win32/cygwin_tools` and they all do
143 conversion of parameters and switches common in the Unix environment
144 to fit the native Windows tools. Most notable is of course the paths,
145 which in Cygwin are Unix-like paths with "forward slashes" (/) and no
146 drive letters, the Cygwin specific command `cygpath` is used for most
147 of the path conversions. Luckily most compilers accept forward slashes
148 instead of backslashes as path separators, one still have to get the
149 drive letters etc right, though. The wrapper scripts are not general
150 in the sense that, for example, would understand and translates
151 every possible gcc option and passes correct options to cl.exe. The
152 principle is that the scripts are powerful enough to allow building of
153 Erlang/OTP, no more, no less. They might need extensions to cope with
154 changes during the development of Erlang, that's one of the reasons I
155 made them into shell-scripts and not Perl-scripts, I believe they are
156 easier to understand and change that way. I might be wrong though,
157 cause another reason I didn't write them in Perl is because I've never
158 liked Perl and my Perl code is no pleasant reading...
160 In `$ERL_TOP`, there is a script called `otp_build`, that script handles
161 the hassle of giving all the right parameters to `configure`/`make` and
162 also helps you set up the correct environment variables to work with
163 the Erlang source under Cygwin.
165 * Q: You use and need Cygwin, but then you haven't taken the time to
166 port Erlang to the Cygwin environment but instead focus on your
167 commercial release, is that really ethical?
169 A: No, not really, but see this as a step in the right direction. I'm
170 aiming at GCC compiled emulators and a Cygwin version, but I really
171 need to do other things as well... In time, but don't hold your
172 breath...
174 * Q: Can I build something that looks exactly as the commercial release?
176 A: Yes, we use the exactly same build procedure.
178 * Q: Which version of Cygwin and other tools do you use then?
180 A: For Cygwin we try to use the latest releases available when
181 building. What versions you use shouldn't really matter, I try to
182 include workarounds for the bugs I've found in different Cygwin
183 releases, please help me to add workarounds for new Cygwin-related
184 bugs as soon as you encounter them. Also please do submit bug reports
150f681 @bufflig ** Empty commit message **
bufflig authored
185 to the appropriate Cygwin developers. The Cygwin GCC we used for %OTP-REL%
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
186 was version 3.4.4. We used VC++ 8.0 (i.e. Visual studio 2005 SP1),
187 Sun's JDK 1.5.0\_17, NSIS 2.37, and Win32 OpenSSL 0.9.8e. Please read
188 the next section for details on what you need.
190 * Q: Can you help me setup X in Cygwin?
192 A: No, unfortunately I haven't got time to help with Cygwin related
193 user problems, please read Cygwin related web sites, newsgroups and
194 mailing lists.
196 * Q: Why is the instruction so long? Is it really that complicated?
198 A: Partly it's long because I babble too much, partly because I've
199 described as much as I could about the installation of the needed
200 tools. Once the tools are installed, building is quite easy. I also
201 have tried to make this instruction understandable for people with
202 limited Unix experience. Cygwin is a whole new environment to some
203 Windows users, why careful explanation of environment variables etc
204 seemed to be in place. The short story, for the experienced and
205 impatient is:
207 * Get and install complete Cygwin (latest)
209 * (Buy and) Install Microsoft Visual studio 2005 and SP1 (or higher)
211 * Get and install Sun's JDK 1.4.2
213 * Get and install NSIS 2.01 or higher (up to 2.30 tried and working)
215 * Get and install OpenSSL 0.9.7c or higher
217 * Get and unpack wxWidgets-2.8.9 or higher to `/opt/local/pgm` inside
218 cygwin.
219 * Open `/cygwin/opt/local/pgm/wxWidgets-2.8.9/build/msw/wx.dsw`
220 * Enable `wxUSE_GLCANVAS`, `wxUSE_POSTSCRIPT` and
221 `wxUSE_GRAPHICS_CONTEXT` in `include/wx/msw/setup.h`
222 * Build all unicode release (and unicode debug) packages
223 * Open `/cygwin/opt/local/pgm/wxWidgets-2.8.9/contrib/build/stc/stc.dsw`
224 * Build the unicode release (and unicode debug) packages
226 * Get the Erlang source distribution (from
227 <>) and unpack with Cygwin's `tar`.
229 * Set `ERL_TOP` to where you unpacked the source distribution
231 * `$ cd $ERL_TOP`
233 * Get (from <>)
234 and unpack the prebuilt TCL/TK binaries for windows with cygwin tar,
235 standing in `$ERL_TOP`
237 * Modify PATH and other environment variables so that all these tools
238 are runnable from a bash shell. Still standing in `$ERL_TOP`, issue
239 the following commands:
241 $ eval `./otp_build env_win32`
242 $ ./otp_build autoconf
243 $ ./otp_build configure
244 $ ./otp_build boot -a
245 $ ./otp_build release -a
246 $ ./otp_build installer_win32
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
247 $ release/win32/otp_win32_%OTP-REL% /S
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
249 Voila! `Start->Programs->Erlang OTP %OTP-REL%->Erlang` starts the Erlang
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
250 Windows shell.
253 Tools you Need and Their Environment
254 ------------------------------------
256 You need some tools to be able to build Erlang/OTP on Windows. Most
257 notably you'll need Cygwin and Microsoft VC++, but you also might want
258 a Java compiler, the NSIS install system and OpenSSL. Only VC++ costs
259 money, but then again it costs a lot of money, I know...
260 Well' here's the list:
262 * Cygwin, the very latest is usually best. Get all the development
263 tools and of course all the basic ditto. In fact getting the complete
264 package might be a good idea, as you'll start to love Cygwin after a
265 while if you're accustomed to Unix. Make sure to get jar and also make
266 sure *not* to install a Cygwin'ish Java... The Cygwin jar command is
267 used but Sun's Java compiler and virtual machine...
269 URL: <>
271 Get the installer from the web site and use that to install
272 Cygwin. Be sure to have fair privileges. If you're on a NT domain you
273 should consider running `mkpasswd -d` and `mkgroup -d` after the
274 installation to get the user databases correct. See their respective
275 manual pages.
277 When you start you first bash shell, you will get an awful prompt. You
278 might also have a `PATH` environment variable that contains backslashes
279 and such. Edit `$HOME/.profile` and `$HOME/.bashrc` to set fair prompts
280 and set a correct PATH. Also do a `export SHELL` in `.profile`. For some
281 non-obvious reason the environment variable `$SHELL` is not exported in
282 bash. Also note that `.profile` is run at login time and `.bashrc` when
283 sub shells are created. You'll need to explicitly source `.bashrc` from
284 `.profile` if you want the commands there to be run at login time (like
285 setting up aliases, shell functions and the like). I personally
286 usually do like this at the end of `.profile`:
288 ENV=$HOME/.bashrc
289 export ENV
290 . $ENV
292 You might also, if you're a hard core type of person at least, want to
293 setup X-windows (XFree86), that might be as easy as running startx
294 from the command prompt and it might be much harder. Use Google to
295 find help...
297 If you don't use X-windows, you might want to setup the Windows
298 console window by selecting properties in the console system menu
299 (upper left corner of the window, the Cygwin icon in the title
300 bar). Especially setting a larger screen buffer size (lines) is useful
301 as it gets you a scrollbar so you can see whatever error messages
302 that might appear...
304 If you want to use (t)csh instead of bash you're on your own, I
305 haven't tried and know of no one that has. I expect
306 that you use bash in all shell examples.
308 * Microsoft Visual Studio 2005 SP1. Please don't skip the service
309 pack! The installer might update your environment so that you can run
310 the `cl` command from the bash prompt, then again it might
311 not... There is always a BAT file in VC\Bin under the installation
312 directory (default `C:\Program Files\Microsoft Visual Studio 8`) called
313 `VCVARS32.BAT`. Either add the environment settings in that file to the
314 global environment settings in Windows or add the corresponding BASH
315 environment settings to your `.profile`/`.bashrc`. For example, in my case
316 I could add the following to `.profile`
318 #Visual C++ Root directory as Cygwin style pathname
319 VCROOT=/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio 8
321 # Visual C++ Root directory as Windows style pathname
322 WIN_VCROOT="C:\\Program Files\\Microsoft Visual Studio 8"
324 # The PATH variable should be Cygwin'ish
325 PATH=$VCROOT/Common7/IDE:$VCROOT/VC/BIN:$VCROOT/Common7/Tools:\
326 $VCROOT/Common7/Tools/bin:$VCROOT/VC/PlatformSDK/bin:$VCROOT/SDK/v2.0/bin:\
327 $VCROOT/VC/VCPackages:$PATH
329 # Lib and INCLUDE should be Windows'ish
330 # Note that semicolon (;) is used to separate Windows style paths but
331 # colon (:) to separate Cygwin ditto!
336 $WIN_VCROOT\\VC\\PlatformSDK\\lib\;$WIN_VCROOT\\SDK\\v2.0\\lib
339 $WIN_VCROOT\\VC\\PlatformSDK\\include
343 Make a simple hello world and try to compile it with the `cl` command
344 from within bash. If that does not work, your environment needs
345 fixing. Also remember to fix up the PATH environment, especially old
346 Erlang installations might have inserted quoted paths that Cygwin does
347 not understand. Remove or correct such paths. There should be no
348 backslashes in your path environment variable in Cygwin bash, but LIB
349 and INCLUDE should contain Windows style paths with semicolon,
350 drive letters and backslashes.
352 If you wish to use Visual Studio 2008, a couple things need to be tweaked,
353 namely the fact that some of the SDK stuff is installed in (by default)
354 `C:\Program Files\Microsoft SDKs\v6.0A` . Just ensure that that
355 `C:\Program Files\Microsoft SDKs\v6.0A\Lib` is in `LIB` and
356 `C:\Program Files\Microsoft SDKs\v6.0A\Include` is in `INCLUDE`. A symptom
357 of not doing this is errors about finding kernel32.lib and windows.h.
359 Additionally, if you encounter errors about mc.exe not being found, you must
360 install the entire Windows SDK (the partial SDK included in visual studio
361 apparently does not include it). After installing it you'll want to add
362 something like: `/c/cygdrive/Program\ Files/Microsoft\ SDKs/v7.0/bin` to
363 your `PATH` to allow the environment to find mc.exe. The next Visual Studio
364 (2010) is expected to include this tool.
366 * Sun's Java JDK 1.5.0 or higher. Our Java code (jinterface, ic) is
367 written for JDK 1.5.0. Get it for Windows and install it, the JRE is
368 not enough. If you don't care about Java, you can skip this step, the
369 result will be that jinterface is not built.
371 URL: <>
373 Add javac *LAST* to your path environment in bash, in my case this means:
375 PATH="$PATH:/cygdrive/c/Program Files/Java/jdk1.5.0_17/bin"
377 No `CLASSPATH` or anything is needed. Type `javac` at the bash prompt
378 and you should get a list of available Java options. Make sure by
379 typing `which java` that you use the Java you installed. Note however that
380 Cygwin's `jar.exe` is used, that's why the JDK bin-directory should be
381 added last in the `PATH`.
383 * Nullsoft NSIS installer system. You need this to build the self
384 installing package. It's a free open source installer that's much
385 nicer to use than the commercial Wise and Install shield
386 installers. This is the installer we use for commercial releases as
387 well from R9C an on.
389 URL: <>
391 Install the lot, especially the modern user interface components, as
392 it's definitely needed. Put `makensis` in your path, in my case:
394 PATH=/cygdrive/c/Program\ Files/NSIS:$PATH
396 type makensis at the bash prompt and you should get a list of options
397 if everything is OK.
399 * OpenSSL for Windows. This is if you want the SSL and crypto
400 applications to compile (and run). Go to <>, click
401 on the `Related` link and then on the `Binaries` link (upper right
402 corner of the page last time I looked), you can then reach the
403 "Shining Lights Productions" Web site for Windows binaries
404 distributions. Get the latest or 0.9.7c if you get trouble with the
405 latest. It's a nifty installer. The rest should be handled by
406 `configure`, you needn't put anything in the path or anything.
408 If you want to build openssl for windows yourself (which might be
409 possible, as you wouldn't be reading this if you weren't a
410 compile-it-yourself person), you either have to put the resulting
411 DLL's in your path or in the windows system directory and either
412 specify where you put the includes etc with the configure-parameter
413 `--with-ssl=<cygwin path to the root>` or put your installation directly
414 under `c:\OpenSSL`. The directory structure under the installation root
415 for OpenSSL is expected to be one with subdirectories named `include`,
416 `bin` and `lib`, possibly with a `VC` subdirectory of `lib` containing
417 the actual `.lib` files. Note that the cygwin distributed OpenSSL cannot be
418 used, it results in cygwin depending binaries and it has unix style
419 archives (`.a`, not `.lib`).
421 * Building with wxWidgets. Download wxWidgets-2.8.9 or higher patch
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
422 release (2.9.\* is a developer release which currently does not work
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
423 with wxErlang).
425 Install or unpack it to `DRIVE:/PATH/cygwin/opt/local/pgm`
426 Open from explorer (i.e. by double clicking the file)
427 `C:\cygwin\opt\local\pgm\wxMSW-2.8.10\build\msw\wx.dsw`
428 In Microsoft Visual Studio, click File/Open/File, locate and
429 open: `C:\cygwin\opt\local\pgm\wxMSW-2.8.10\include\wx\msw\setup.h`
431 Build it by clicking Build/Batch Build and select all unicode release
432 (and unicode debug) packages.
434 Open `C:\cygwin\opt\local\pgm\wxMSW-2.8.10\contrib/build/stc/stc.dsw`
435 and batch build all unicode packages.
437 * The Erlang source distribution (from <>).
438 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
rickard-green authored
439 unpack the source tar.gz (`tar zxf otp_src_%OTP-REL%.tar.gz`).
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
441 set the environment `ERL_TOP` to point to the root directory of the
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
442 source distribution. Let's say I stood in `$HOME/src` and unpacked
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
443 `otp_src_%OTP-REL%.tar.gz`, I then add the following to `.profile`:
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
445 ERL_TOP=$HOME/src/otp_src_%OTP-REL%
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
446 export $ERL_TOP
448 * The TCL/TK binaries. You could compile Tcl/Tk for windows yourself,
449 but you can get a stripped down version from our website which is
450 suitable to include in the final binary package. If you want to supply
451 tcl/tk yourself, read the instructions about how the tcl/tk tar file
452 used in the build is constructed under `$ERL_TOP/lib/gs/tcl`. The easy
453 way is to download <>
454 and unpack it standing in the `$ERL_TOP` directory. This will create the
455 file `win32.tar.gz` in `$ERL_TOP/lib/gs/tcl/binaries`.
457 One last alternative is to create a file named `SKIP` in the
458 `$ERL_TOP/lib/gs/` after configure is run, but that will give you an
459 erlang system without gs (which might be okay as you probably will use
460 wx anyway).
462 The Shell Environment
463 ---------------------
465 So, if you have followed the instructions above, when you start a bash
466 shell, you should have an INCLUDE environment with a Windows style
467 path, a LIB environment variable also in Windows style, and finally a
468 PATH that let's you reach cl, makensis, javac etc from the
469 command prompt (use `which cl` etc to verify from bash).
471 You should also have an `ERL_TOP` environment variable that is *Cygwin
472 style*, and points to a directory containing, among other files, the
473 script `otp_build`.
475 A final massage of the environment is needed, and that is done by
476 the script `$ERL_TOP/otp_build`. Start bash and do the following, note
477 the "back-ticks" (\`), can be quite hard to get on some keyboards, but
478 pressing the back-tick key followed by the space bar might do it...
480 $ cd $ERL_TOP
481 $ eval `./otp_build env_win32`
483 If you're unable to produce back-ticks on your keyboard, you can use
484 the ksh variant:
486 $ cd $ERL_TOP
487 $ eval $(./otp_build env_win32)
489 This should do the final touch to the environment and building should
490 be easy after this. You could run `./otp_build env_win32` without
491 `eval` just to see what it does, and to see that the environment it
492 sets seems OK. The path is cleaned of spaces if possible (using DOS
493 style short names instead), the variables `OVERRIDE_TARGET`, `CC`, `CXX`,
494 `AR` and `RANLIB` are set to their respective wrappers and the directories
495 `$ERL_TOP/erts/etc/win32/cygwin_tools/vc` and
496 `$ERL_TOP/erts/etc/win32/cygwin_tool` are added first in the PATH.
498 Try now a `which erlc`. That should result in the erlc wrapper script
499 (which does not have the .sh extension, for reasons best kept
500 untold...). It should reside in `$ERL_TOP/erts/etc/win32/cygwin_tools`.
501 You could also try `which`, which `` etc.
503 Now you're ready to build...
506 Building and Installing
507 -----------------------
509 Now it's assumed that you have executed `` eval `./otp_build env_win32` ``
510 for this particular shell...
512 Building is easiest using the `otp_build` script. That script takes care
513 of running configure, bootstrapping etc on Windows in a simple
514 way. The `otp_build` script is the utility we use ourselves to build on
515 different platforms and it therefore contains code for all sorts of
516 platforms. The principle is, however, that for non-Unix platforms, one
517 uses `./otp_build env_<target>` to set up environment and then the
518 script knows how to build on the platform "by itself". You've already
519 run `./otp_build env_win32` in the step above, so now it's mostly like
520 we build on any platform. OK, here are then steps; Assuming you will
521 want to build a full installation executable with NSIS, you can omit
522 `<installation directory>` and the release will be copied to
523 `$ERL_TOP/release/win32`: and there is where the packed self installing
524 executable will reside too.
526 $ ./otp_build autoconf # Ignore the warning blob about versions of autoconf
527 $ ./otp_build configure <optional configure options>
528 $ ./otp_build boot -a
529 $ ./otp_build release -a <installation directory>
530 $ ./otp_build installer_win32 <installation directory> # optional
532 Now you will have a file called `otp_win32_R12B.exe` in the
533 `<installation directory>`, i.e. `$ERL_TOP/release/win32`.
535 Lets get into more detail:
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
537 1. `$ ./otp_build autoconf` - This step rebuilds the configure scripts
538 to work correctly in the cygwin environment. In an ideal world, this
539 would not be needed, but alas, we have encountered several
540 incompatibilities between our distributed configure scripts (generated
541 on a Linux platform) and the cygwin environment over the
542 years. Running autoconf on cygwin ensures that the configure scripts
543 are generated in a cygwin-compatible way and that they will work well
544 in the next step.
546 2. `$ ./otp_build configure` - This runs the newly generated configure
547 scripts with options making configure behave nicely. The target machine
548 type is plainly `win32`, so a lot of the configure-scripts recognize
549 this awkward target name and behave accordingly. The CC variable also
550 makes the compiler be ``, which wraps MSVC++, so all configure
551 tests regarding the C compiler gets to run the right compiler. A lot of
552 the tests are not needed on Windows, but I thought it best to run the
553 whole configure anyway. The only configure option you might want to
554 supply is `--with-ssl`, which might be needed if you have built your
555 own OpenSSL distribution. The Shining Lights distribution should be
556 found automatically by `configure`, if that fails, add a
557 `--with-ssl=<dir>` that specifies the root directory of your OpenSSL
558 installation.
560 3. `$ ./otp_build boot -a` - This uses the bootstrap directory (shipped
561 with the source, `$ERL_TOP/bootstrap`) to build a complete OTP
562 system. It first builds an emulator and sets up a minimal OTP system
563 under `$ERL_TOP/bootstrap`, then starts to compile the different OTP
564 compilers to make the `$ERL_TOP/bootstrap` system potent enough to be
565 able to compile all Erlang code in OTP. Then, all Erlang and C code
566 under `$ERL_TOP/lib` is built using the bootstrap system, giving a
567 complete OTP system (although not installed). When this is done, one
568 can run Erlang from within the source tree, just type `$ERL_TOP/bin/erl`
569 and you should have a prompt. If you omit the -a flag, you'll get a
570 smaller system, that might be useful during development. Now
571 exit from Erlang and start making a release of the thing:
573 4. `$ ./otp_build release -a` - Builds a commercial release tree from the
574 source tree, default is to put it in `$ERL_TOP/release/win32`, you can
575 give any directory as parameter (Cygwin style), but it doesn't really
576 matter if you're going to build a self extracting installer too. You
577 could of course build release to the final directory and then run
578 `./Install.exe` standing in the directory where the release was put,
579 that will create a fully functional OTP installation. But let's make
580 the nifty installer:
582 5. `$ ./otp_build installer_win32` - Create the self extracting installer
583 executable. The executable `otp_win32_%OTP-REL%.exe` will be placed
584 in the top directory of the release created in the previous step. If
585 no release directory is specified, the release is expected to have
586 been built to `$ERL_TOP/release/win32`, which also will be the place
587 where the installer executable will be placed. If you specified some
588 other directory for the release (i.e. `./otp_build release -a
589 /tmp/erl_release`), you're expected to give the same parameter here,
590 (i.e. `./otp_build installer_win32 /tmp/erl_release`). You need to have
591 a full NSIS installation and `makensis.exe` in your path for this to
592 work of course. Once you have created the installer, you can run it to
593 install Erlang/OTP in the regular way, just run the executable and
594 follow the steps in the installation wizard. To get all default settings
595 in the installation without any questions asked, you run the executable
596 with the parameter `/S` (capital S) like in:
598 $ cd $ERL_TOP
599 $ release/win32/otp_win32_%OTP-REL% /S
600 ...
602 and after a while Erlang/OTP-%OTP-REL% will have been installed in
603 `C:\Program Files\erl%ERTS-VSN%\`, with shortcuts in the menu etc.
605 The necessary setup of an Erlang installation is actually done by the
606 program `Install.exe`, which resides in the release top. That program
607 creates `.ini`-files and copies the correct boot scripts. If one has
608 the correct directory tree (like after a `./otp_build release -a`), only
609 the running of `Install.exe` is necessary to get a fully functional
610 OTP. What the self extracting installer adds is (of course) the
611 possibility to distribute the binary easily, together with adding
612 shortcuts to the Windows start menu. There is also some adding of
613 entries in the registry, to associate `.erl` and `.beam` files with
614 Erlang and get nifty icons, but that's not something you'll really need
615 to run Erlang. The registry is also used to store uninstall information,
616 but if one has not used the self extracting installer, one cannot
617 (need not) do any uninstall, one just scratches the release directory
618 and everything is gone. Erlang/OTP does not *need* to put anything
619 in the Windows registry at all, and does not if you don't use the self
620 extracting installer. In other words the installer is pure cosmetics.
622 > *NOTE*: Beginning with R9C, the Windows installer does *not* add Erlang
623 > to the system wide path. If one wants to have Erlang in the path, one
624 > has to add it by hand.
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
626 Development
627 -----------
629 Once the system is built, you might want to change it. Having a test
630 release in some nice directory might be useful, but you also can run
631 Erlang from within the source tree. The target `local_setup`, makes
632 the program `$ERL_TOP/bin/erl.exe` usable and it also uses all the OTP
633 libraries in the source tree.
635 If you hack the emulator, you can then build the emulator executable
636 by standing in `$ERL_TOP/erts/emulator` and do a simple
638 $ make opt
640 Note that you need to have run ``(cd $ERL_TOP && eval `./otp_build env_win32`)``
641 in the particular shell before building anything on Windows. After
642 doing a make opt you can test your result by running `$ERL_TOP/bin/erl`.
643 If you want to copy the result to a release directory (say
644 `/tmp/erl_release`), you do this (still in `$ERL_TOP/erts/emulator`)
646 $ make TESTROOT=/tmp/erl_release release
648 That will copy the emulator executables.
650 To make a debug build of the emulator, you need to recompile both
651 `beam.dll` (the actual runtime system) and `erlexec.dll`. Do like this
653 $ cd $ERL_TOP
654 $ rm bin/win32/erlexec.dll
655 $ cd erts/emulator
656 $ make debug
657 $ cd ../etc
658 $ make debug
660 and sometimes
662 $ cd $ERL_TOP
663 $ make local_setup
665 So now when you run `$ERL_TOP/erl.exe`, you should have a debug compiled
666 emulator, which you will see if you do a:
668 1> erlang:system_info(system_version).
670 in the erlang shell. If the returned string contains `[debug]`, you
671 got a debug compiled emulator.
673 To hack the erlang libraries, you simply do a `make opt` in the
674 specific "applications" directory, like:
676 $ cd $ERL_TOP/lib/stdlib
677 $ make opt
679 or even in the source directory...
681 $ cd $ERL_TOP/lib/stdlib/src
682 $ make opt
684 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
rickard-green authored
685 doing this, preferably the plain %OTP-REL% you have built in the previous
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
686 steps. You could also add `$ERL_TOP/bootstrap/bin` to your `PATH` before
687 rebuilding specific libraries, that would give you a good enough
688 Erlang system to compile any OTP erlang code. Setting up the path
689 correctly is a little bit tricky, you still need to have
690 `$ERL_TOP/erts/etc/win32/cygwin_tools/vc` and
691 `$ERL_TOP/erts/etc/win32/cygwin_tools` *before* the actual emulator
692 in the path. A typical setting of the path for using the bootstrap
693 compiler would be:
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
695 $ export PATH=$ERL_TOP/erts/etc/win32/cygwin_tools/vc\
696 :$ERL_TOP/erts/etc/win32/cygwin_tools:$ERL_TOP/bootstrap/bin:$PATH
7aa2cb2 @rickard-green OTP-8449 Documentation improvements.
rickard-green authored
698 That should make it possible to rebuild any library without hassle...
700 If you want to copy a library (an application) newly built, to a
701 release area, you do like with the emulator:
703 $ cd $ERL_TOP/lib/stdlib
704 $ make TESTROOT=/tmp/erlang_release release
706 Remember that:
708 * Windows specific C-code goes in the `$ERL_TOP/erts/emulator/sys/win32`,
709 `$ERL_TOP/erts/emulator/drivers/win32` or `$ERL_TOP/erts/etc/win32`.
711 * Windows specific erlang code should be used conditionally and the
712 host OS tested in *runtime*, the exactly same beam files should be
713 distributed for every platform! So write code like:
715 case os:type() of
716 {win32,_} ->
717 do_windows_specific();
718 Other ->
719 do_fallback_or_exit()
720 end,
722 That's basically all you need to get going.
724 Final Words
725 -----------
726 My hope is that the possibility to build the whole system on Windows
727 will open up for free development on this platform too. There are many
728 things one might want to do better in the Windows version, like the
729 window-style command prompt as well as pure Cygwin porting. Although i
730 realize it's a much larger step to start building on Windows (with all
731 the software you need) than for instance on Linux, I sincerely hope
732 that some of you will make the effort and start submitting Windows
733 friendly patches.
735 The first build system for Erlang using Cygwin on Windows was created
736 by Per Bergkvist. I haven't used his build system, but it's rumored to
737 be good. The idea to do this came from his work, so credit is well
738 deserved.
740 Of course this would have been completely impossible without the
741 excellent Cygwin package. The guys at Cygnus solutions and Redhat
742 deserves a huge THANKS! as well as all the other people in the free
743 software community who have helped in creating the magnificent
744 software that constitutes Cygwin.
746 Good luck and Happy Hacking,
747 Patrik, OTP
749 Copyright and License
750 ---------------------
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
752 %CopyrightBegin%
754 Copyright Ericsson AB 2003-2010. All Rights Reserved.
756 The contents of this file are subject to the Erlang Public License,
757 Version 1.1, (the "License"); you may not use this file except in
758 compliance with the License. You should have received a copy of the
759 Erlang Public License along with this software. If not, it can be
760 retrieved online at
762 Software distributed under the License is distributed on an "AS IS"
763 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
764 the License for the specific language governing rights and limitations
765 under the License.
767 %CopyrightEnd%
769 Modifying This Document
770 -----------------------
772 Before modifying this document you need to have a look at the
773 `$ERL_TOP/` document.
4c3aebe @rickard-green OTP-8457 Minor documentation fixes. Mainly anchor adjustments.
rickard-green authored
777 [1]: "mailing lists"
d041cab @rickard-green OTP-8512 Add Erlangish MarkDown to Erlangish XML support
rickard-green authored
779 [?TOC]: true
Something went wrong with that request. Please try again.