6136
|
1 Compiling Octave with MSVC |
|
2 |
|
3 Starting with Octave 2.9.9, Octave source tree contains support for |
|
4 MSVC (Microsoft C/C++ compiler). This file explains how to |
|
5 successfully compile Octave under such a system. |
|
6 |
|
7 |
|
8 1. Requirements |
|
9 =============== |
|
10 |
|
11 Depending whether you are compiling Octave from a release package or |
|
12 from CVS source tree, various additional tools are required. |
|
13 |
|
14 1.1 Shell |
|
15 --------- |
|
16 |
|
17 The compilation process requires a working UNIX-like shell under |
|
18 Windows. Such shell is provided either by Cygwin or MSYS (MinGW). |
|
19 The choice of the actual shell will have an impact on the rest of the |
|
20 procedure. Altough both shell can be used, the procedure has been |
|
21 mainly tested under the MSYS shell. |
|
22 |
|
23 1.1.1 Cygwin shell |
|
24 |
|
25 The use of the Cygwin shell has the advantage of installation |
|
26 simplicity, as all required packages can be easily installed through |
|
27 the setup program. However it presents some annoying compile-time |
|
28 problems. The Cygwin shell can be installed via the setup program |
|
29 http://www.cygwin.com/setup.exe. You should at least select the |
|
30 following packages |
|
31 |
|
32 bash grep sed make |
|
33 |
|
34 If you are building the CVS sources of Octave, you will also need |
|
35 |
|
36 gawk bison flex autoconf tetex texinfo ghostscript |
|
37 |
|
38 When building from CVS, you need also gperf. However, the version |
|
39 available under Cygwin is too old, so you should grab a more recent |
|
40 one. You can either build gperf from the sources found at |
|
41 ftp://ftp.gnu.org or use the package from the GunWin32 project |
|
42 (http://gnuwin32.sourceforge.net). Either way, get the gperf package, |
|
43 install it and make sure the executable is in your PATH under the |
|
44 Cygwin shell. |
|
45 |
|
46 1.1.2 MSYS shell |
|
47 |
|
48 The use of the MSYS shell requires more manual installation, but |
|
49 currently results in fewer compile-time problem. Download and install |
|
50 the following packages from the MinGW download page |
|
51 (http://www.mingw.org): |
|
52 |
|
53 MSYS-1.0.10.exe |
|
54 msysDTK-1.0.1.exe |
|
55 |
|
56 If you are building the CVS sources of Octave, you will also need |
|
57 |
|
58 msys-autoconf-2.59.tar.bz2 |
|
59 |
|
60 from the MinGW site. |
|
61 |
|
62 NOTE: the autoconf version included in msysDTK is too old (2.56). |
|
63 Grab the newer one and simply uncompress it in the root |
|
64 directory of the MSYS installation directory. |
|
65 |
6653
|
66 If you are building from CVS, you will need the following |
6136
|
67 additional tools that are not part of the MSYS packages |
|
68 |
|
69 bison flex gperf |
|
70 |
|
71 You can find these packages as part of the GnuWin32 project |
|
72 (http://gnuwin32.sourceforge.net) or you can build them from sources |
|
73 found at ftp://ftp.gnu.org. Download and install these packages and |
|
74 make sure the executables are in your PATH under the MSYS shell. |
|
75 |
|
76 Building the documentation from CVS also requires additional tools, |
|
77 mainly TeX, texinfo and ghostscript. MiKTeX (http://www.miktex.org) |
|
78 provides a user-friendly TeX implementation under Windows, with an |
|
79 easy-to-use installer. Download and install MiKTeX if you're building |
|
80 from CVS, and make sure the executables (located in |
|
81 <MiKTeX_install>\Main\miktex\bin) are in your PATH under the MSYS shell. |
|
82 |
|
83 MiKTeX also provides texinfo. However, the msysDTK package provides |
|
84 an out-dated version that cannot be used to build Octave |
|
85 documentation. So you should make sure that you're using the MiKTeX |
|
86 implementation, by either playing with your PATH variable or renaming |
|
87 the makeinfo.exe, texi2dvi and texi2pdf files located in the directory |
|
88 <MSYS_install>\bin. |
|
89 |
|
90 Ghostscript is available from http://www.cs.wisc.edu/~ghost/. |
|
91 Download and install the package gsxxxw32.exe, where xxx stands for |
|
92 the actual release or ghostscript (as of writing this documentation, |
|
93 version is 8.54; hence the package is named gs854w32.exe). Again, |
|
94 make sure the gswin32.exe executable is in your PATH under the MSYS |
|
95 shell. |
|
96 |
|
97 1.2 Gnuplot |
|
98 ----------- |
|
99 |
|
100 Octave relies on gnuplot for plotting. It is not necessary to install |
|
101 gnuplot just to build the Octave executable, but it is needed to |
|
102 create some figures for the documentation if you are building the CVS |
|
103 sources of Octave. |
|
104 |
|
105 A Windows version of Gnuplot can be found at http://www.gnuplot.info. |
|
106 Download and install it, and make sure the pgnuplot.exe executable is |
|
107 in your PATH under the shell. |
|
108 |
|
109 1.3 MSVC compiler |
|
110 ----------------- |
|
111 |
|
112 You'll need a recent MSVC compiler. This compiler is available for |
|
113 free (as in beer) from Microsoft MSDN web site. Octave has been |
|
114 successfully compiled using version 8 of the compiler (AKA Visual |
|
115 Studio 2005). To start a command prompt with the correct compilation |
|
116 environment, use the corresponding menu entry in your start menu. |
|
117 |
|
118 If you're using the free version of Visual Studio (Express edition), |
|
119 you'll need to install the Platform SDK package, also available from |
|
120 MSDN. In that case, you'll also need to run the "SetEnv.cmd" script |
|
121 found in the SDK installation directory for the required additional |
|
122 setup. |
|
123 |
|
124 1.4 Unix-to-MSVC compilation scripts |
|
125 ------------------------------------ |
|
126 |
|
127 These scripts provide a UNIX-like compilation interface, based on the |
|
128 Microsoft compilation tools. The package is available from the Octave |
|
129 web site. Download and install the package, and make sure the scripts |
|
130 are in your PATH under the shell. |
|
131 |
|
132 As those scripts calls the Microsoft compilation tools, those tools |
|
133 should also be in your PATH. I've found that the easiest way to get a |
|
134 correct environment is to start the shell from the command prompt that |
|
135 is already configured for MSVC. |
|
136 |
|
137 Hence the following steps: |
|
138 |
|
139 * start command prompt from Visual Studio menu entry |
|
140 |
|
141 * run "SetEnv.cmd" if required |
|
142 |
|
143 * additional setup (like adding Gnuplot, GnuWin32 bin |
|
144 directory... to the PATH) |
|
145 |
|
146 * start the shell: |
|
147 |
|
148 - MSYS: start <MSYS_install>\bin\rxvt.exe -e /bin/sh --login -i |
|
149 - Cygwin: start <Cygwin_install>\cygwin.bat |
|
150 |
|
151 1.5 Glob library |
|
152 ---------------- |
|
153 |
|
154 Octave also requires a filename globbing library. This library is |
|
155 typically part of the C library on UNIX systems, but is not part of |
|
156 the Windows or MSVC run-time libraries. You can find a glob package |
|
157 on the Octave website. This package provides the missing features and |
|
158 is intended to be compiled in a fully setup shell with the |
|
159 Unix-to-MSVC compilation scripts: |
|
160 |
|
161 * download and decompress the sources |
|
162 * run "./configure.vc" (you can edit it to change the installation dir) |
|
163 * run "make" |
|
164 * run "make install" |
|
165 |
|
166 Then you'll have to tell MSVC where to find the headers and library |
|
167 files by adjusting the INCLUDE and LIB environment variables. This |
|
168 can be done before starting the shell, in the "additional setup" step |
|
169 (see above). |
|
170 |
|
171 1.6 Readline library |
|
172 -------------------- |
|
173 |
|
174 While not mandatory to compile Octave, the readline library is very |
|
175 useful to make Octave really usable. A patched version of the |
|
176 readline library can be found in the Octave website. This patched |
|
177 version is intended to be compiled from the shell using the |
|
178 Unix-to-MSVC compilation scripts: |
|
179 |
|
180 * download and decompress the sources (and apply the patch, if required) |
|
181 * follow the instructions in the file README.msvc |
|
182 |
|
183 As for the glob library, adapt the INCLUDE and LIB environment |
|
184 variables. Note that as Octave will be linked to the readline DLL, |
|
185 you should also add the path of readline.dll to your PATH variable. |
|
186 |
|
187 1.7 F2C |
|
188 ------- |
|
189 |
|
190 As there exist no free MSVC-like fortran compiler, the compilation |
|
191 process makes use of the f2c utility and the libf2c library. Those |
|
192 components can be downloaded from http://www.netlib.org/f2c/msdos/ and |
|
193 http://www.netlib.org/f2c/libf2c.zip. |
|
194 |
|
195 To compile libf2c, use makefile.vc and NMAKE.EXE. To be usable within |
6275
|
196 Octave, the following modifications needs to be done: |
|
197 1) edit makefile.vc and add "-MD" as compilation flag (to |
|
198 the CFLAGS variable). |
|
199 2) edit fio.h and comment the declaration of isatty (around line 112). |
|
200 This means replacing the line: |
|
201 |
|
202 extern int isatty(int); |
|
203 |
|
204 with |
|
205 |
|
206 /* extern int isatty(int); */ |
|
207 |
|
208 After compilation, install f2c.h and vcf2c.lib at locations where they |
|
209 can be found by the MSVC tools (adjust the INCLUDE and LIB variables). |
|
210 Note that you must rename vcf2c.lib into f2c.lib so that Octave's |
|
211 configure script will find it. |
6136
|
212 |
|
213 |
|
214 2. Compilation |
|
215 ============== |
|
216 |
|
217 Copy the following lines into a shell script and execute it (note that |
|
218 you can use whatever you want as installation directory): |
|
219 |
|
220 --- BEGIN (cut me) |
|
221 #!/bin/sh |
|
222 if ! grep "__declspec(noreturn dllimport)" configure 2>&1 > /dev/null; then |
|
223 echo "Pre-processing configure script..." |
|
224 sed -e "s/'extern \"C\" void exit (int);'/'extern \"C\" __declspec(noreturn dllimport) void exit (int);' 'extern \"C\" void exit (int);'/g" configure \ |
|
225 > configure.tmp |
|
226 mv configure.tmp configure |
|
227 fi |
|
228 |
|
229 CC=cc-msvc CXX=cc-msvc NM="dumpbin -symbols" AR=ar-msvc RANLIB=ranlib-msvc \ |
|
230 ./configure --build=i686-pc-msdosmsvc --prefix=/usr/local/octave-vc8-debug --with-f2c |
|
231 --- END (cut me) |
|
232 |
|
233 Then run the usual: |
|
234 |
|
235 make |
|
236 make install |
|
237 |
|
238 2.1 MSYS |
|
239 -------- |
|
240 |
|
241 When building from the MSYS shell and CVS, everything should run fine |
|
242 until building the doc. At some point, TeX might ask you for the |
|
243 location of the file conf.texi. If this happens, simply type |
|
244 "../conf.texi" and the process should continue. |
|
245 |
|
246 2.2 Cygwin |
|
247 ---------- |
|
248 |
|
249 Building from the Cygwin shell and CVS produces more compile-time |
|
250 errors when generating the documentation. Here are some fixes that |
|
251 should work around most problems: |
|
252 |
|
253 * edit "run-octave" and add the 2 lines right after the definition of |
|
254 LOADPATH and IMAGEPATH: |
|
255 |
|
256 LOADPATH=`cygpath -d -p $LOADPATH` |
|
257 IMAGEPATH=`cygpath -d $IMAGEPATH` |
|
258 |
|
259 * if texi2dvi fails with the error "Fatal error: I'm stymied", defines TEX |
|
260 variable to "tex" as in: "TEX=tex make" |
|
261 |
|
262 * if pdftex fails in doc/refcard with the same error as above, edit |
|
263 the Makefile and replace "pdftex" calls with "pdfetex" |
|
264 |
|
265 |
|
266 3. Installation |
|
267 =============== |
|
268 |
|
269 The compiled Octave is relocatable. This means that whetever |
|
270 installation dir you chose at configure time, you can move the whole |
|
271 installation directory to another location without any problem. Octave |
|
272 should still run OK. |
|
273 |
|
274 |
|
275 4. Notes |
|
276 ======== |
|
277 |
|
278 This procedure has been successfully tested under Windows XP with |
|
279 Visual Studio 2005 Express edition, Platform SDK for Windows Server |
|
280 2003 R2, patched readline version 5.2, APFL ghostscript 8.54, Gnuplot |
|
281 4.0, MSYS-1.0.10, msysDTK-1.0.1, MiKTeX-2.4. Depending on your |
|
282 configuration, it may or may not work for you. |
|
283 |
|
284 |
|
285 Please send questions, comments or suggestions to |
|
286 |
|
287 Michael Goffioul |
|
288 michael dot goffioul at swing dot be |
|
289 |
|
290 Thu Nov 2 11:30:50 2006 |