The R Project SVN R

Rev

Rev 32748 | Rev 36544 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32748 Rev 33027
Line 6... Line 6...
6
 
6
 
7
 
7
 
8
Building from a source-code library under Windows
8
Building from a source-code library under Windows
9
=================================================
9
=================================================
10
 
10
 
11
[If you are reading this file as part of the full R source distribution,
-
 
12
you need to build R first: see file INSTALL.]
-
 
13
 
-
 
14
 
-
 
15
    *** This file contains a lot of prescriptive comments.  They are
11
Instructions for installing the toolset and building packages using the
16
    here as a result of bitter experience.  Please do not report problems
-
 
17
    to R-help unless you have followed all the prescriptions. ***
-
 
18
 
-
 
19
 
-
 
20
If your package has no C nor Fortran nor C++ sources, see `Simple ports' 
-
 
21
near the bottom of this file.
-
 
22
 
-
 
23
First collect the tools that you need.  There is a `portal' with
-
 
24
current links at http://www.murdoch-sutherland.com/Rtools/.
-
 
25
 
-
 
26
 
-
 
27
You will need suitable versions of at least make, sh, cat, cp, diff,
-
 
28
echo, mkdir, mv, rm, sed; we have packaged a set at
-
 
29
http://www.murdoch-sutherland.com/Rtools/tools.zip extracted from the
-
 
30
cygwin distribution (http://www.cygwin.com/mirrors.html) or (gzip)
-
 
31
compiled from the sources.
-
 
32
 
-
 
33
 
-
 
34
BEWARE: `Native' ports of make are _not_ suitable (including that at
-
 
35
the mingw site).  There were also problems with several earlier
-
 
36
versions of the cygwin tools and dll.  To avoid frustration, please
12
standard methods are in the `R Installation and Administration' manual
37
use our tool set, and make sure it is at the front of your path
-
 
38
(including before the Windows system directories).  If you are using a
-
 
39
Windows shell, type PATH at the prompt to find out.
-
 
40
 
-
 
41
 
-
 
42
You need a recent version of the Mingw port of gcc from
-
 
43
http://sourceforge.net/projects/mingw/.  There will be a distribution
-
 
44
called something like MinGW-3.1.0-1.exe (which is built from
-
 
45
gcc-3.2.3).  Earlier versions may work, but mingw-runtime >= 3.0 and
-
 
46
w32api >= 2.0 are essential.  The releases of gcc-3.3.1, 3.4.1 and 3.4.2 
-
 
47
have also been tested successfully.
-
 
48
Jan 2005: There is now a release candidate of MinGW-3.2.0: please use that.
-
 
49
 
-
 
50
 
-
 
51
The Windows port of perl5, available via
-
 
52
http://www.activestate.com/Products/ActivePerl/.
-
 
53
BEWARE: you do need the *Windows* port and not the Cygwin one.
-
 
54
 
-
 
55
 
-
 
56
If you want to make compiled html (.chm) files you will need the
-
 
57
Microsoft HTML Help Workshop, currently available for download at
-
 
58
http://msdn.microsoft.com/library/en-us/htmlhelp/html/hwmicrosofthtmlhelpdownloads.asp
-
 
59
and http://www.microsoft.com/office/ork/xp/appndx/appa06.htm
-
 
60
 
-
 
61
You may need this on the same drive as the other tools. (Although we
-
 
62
have successfully used it elsewhere, others have reported problems).
-
 
63
 
-
 
64
 
-
 
65
For large packages it is helpful to make zipped help and/or data
13
(which is available in various formats as R-admin.* in the doc/manual
66
files: for that you need zip and unzip from the Info-ZIP project
-
 
67
(www.info-zip.org and mirrors, and included in our tools.zip).
-
 
68
 
-
 
69
 
-
 
70
All of these need to be installed and in your path, and the
-
 
71
appropriate environment variables set.  
-
 
72
Edit MkRules to set the appropriate paths as needed.
-
 
73
BEWARE: MkRules contains tabs and some editors (e.g. WinEdt) silently 
-
 
74
remove them.
14
directory).
75
 
-
 
76
Do not use filepaths with spaces in: you can always use the short forms
-
 
77
(found by dir /x at the Windows command line).
-
 
78
Do not use unnecessary quotes in your PATH variable.
-
 
79
Do not have our toolset and any other version of cygwin1.dll in your path.
-
 
80
 
-
 
81
 
-
 
82
BEWARE: if you have Norton Anti-Virus you may need to disable it.
-
 
83
Some versions lock up the machine when windres is run.  (Norton
-
 
84
Anti-Virus 2002 causes no problems.)
-
 
85
 
-
 
86
BEWARE: Don't expect this to work if the path to R_HOME contains spaces.
-
 
87
It may work, but we don't recommend it.
-
 
88
 
-
 
89
Then
-
 
90
 
-
 
91
	cd R_HOME\src\gnuwin32
-
 
92
	make libR.a libRblas.a
-
 
93
 
-
 
94
which might take up to a minute.  This only needs to be done once for
-
 
95
each R release, and will be done automatically when needed if
-
 
96
omitted at this point.
-
 
97
 
-
 
98
 
-
 
99
At this point there are two approaches:
-
 
100
 
-
 
101
1) Streamlined way
-
 
102
 
-
 
103
Assuming that ...\rw10xx\bin is in your path, use
-
 
104
 
-
 
105
	R CMD INSTALL package
-
 
106
 
-
 
107
where `package' can be a directory or a .tar.gz file.  See
-
 
108
R CMD INSTALL --help for a full list of options, which include
-
 
109
 
-
 
110
  -l, --library=LIB	install packages to library tree LIB
-
 
111
      --docs=TYPE	type(s) of documentation to build and install
-
 
112
      --use-zip-data	collect data files in zip archive
-
 
113
      --use-zip-help	collect help and examples into zip archives
-
 
114
      --use-zip		combine `--use-zip-data' and `--use-zip-help'
-
 
115
 
-
 
116
TYPE can be "none" or "normal" or "chm" (the default) or "all"
-
 
117
 
-
 
118
 
-
 
119
2) Manual `full-control'
-
 
120
 
-
 
121
For each package you want to install, unpack it to a directory, say
-
 
122
mypkg, in R_HOME\src\library, and run
-
 
123
 
-
 
124
	cd R_HOME\src\gnuwin32
-
 
125
	make pkg-mypkg
-
 
126
 
-
 
127
 
-
 
128
Customising compilation
-
 
129
=======================
-
 
130
 
-
 
131
The Makefiles can be customized: in particular the name of the DLL can
-
 
132
be set (for example we once needed integrate-DLLNM=adapt), the compile
-
 
133
flags can be set (see the examples in MakeDll) and the types of help
-
 
134
(if any) to be generated can be chosen (variables HELP and WINHELP).
-
 
135
The simplest way to customize the compilation steps is to set variables in
-
 
136
a file src\Makevars.win, which will automatically be included by MakeDLL.
-
 
137
For example, for RODBC src\Makevars.win could include the line
-
 
138
 
-
 
139
DLLLIBS+=-lodbc32
-
 
140
 
15
 
141
or, equivalently,
-
 
142
 
-
 
143
RODBC-DLLLIBS=-lodbc32
-
 
144
 
-
 
145
If you have a file src\Makefile.win, that will be used as the makefile
-
 
146
for source compilation in place of our makefile MakeDll.
-
 
147
 
-
 
148
BEWARE: files src\Makefile or src\Makevars will be used if they exist
-
 
149
and the .win equivalents do not.  Such files included in package
-
 
150
sources are usually designed for use under Unix and are best removed.
16
This file contains instructions for non-standard situations:
151
 
-
 
152
BEWARE: references to variables in R.dll are converted to the
-
 
153
right form by using the header files.  You must include them.
-
 
154
 
-
 
155
 
17
 
156
Using zipped help files
18
 - Using Microsoft Visual C++
157
=======================
-
 
158
 
-
 
159
You will need zip installed, of course. Just run
-
 
160
 
-
 
161
	make ziponly-mypkg
-
 
162
 
-
 
163
after building mypkg.  Target `ziphelp-mypkg' will make the zip files
-
 
164
but not remove the separate files: this can be used for testing.
-
 
165
 
-
 
166
This is an option to R CMD INSTALL.
-
 
167
 
-
 
168
 
-
 
169
Using zipped data files
19
 - Using Borland C++
170
=======================
-
 
171
 
-
 
172
You will need zip installed. Just run
-
 
173
 
-
 
174
	make zipdata-mypkg
-
 
175
 
-
 
176
after building mypkg.  This is recommended if you have either many small
-
 
177
data files (as in package Devore5) or a few large data files.
-
 
178
 
-
 
179
This is an option to R CMD INSTALL.
-
 
180
 
-
 
181
 
-
 
182
Checking and building packages
20
 - Using other compilers and languages
183
==============================
-
 
184
 
-
 
185
`R CMD check mypkg' can be used just as on Unix.  Use `R CMD check
-
 
186
--help' for full details.  There is an analogous call for build.
-
 
187
 
-
 
188
You may need to set TMPDIR to (the absolute path to) a suitable
-
 
189
temporary directory: the default is c:/TEMP.  (Use forward slashes,
-
 
190
although the code will try to convert backslashes as from 1.7.0.  Do
-
 
191
not have spaces in the filepath, although from 1.9.0 we attempt to
-
 
192
work around this.)
-
 
193
 
-
 
194
These have been used successfully under NT/2000/XP.  We have seen
-
 
195
problems with some Perl versions on Win 95/98/ME, but believe these
-
 
196
are now resolved.  `make pkgcheck-mypkg' will perform the tests of the
-
 
197
examples and tests directory, as far as we know on all versions of
-
 
198
Windows.
-
 
199
 
-
 
200
 
-
 
201
Building the package reference manual
21
 - Cross-building packages on Linux
202
=====================================
-
 
203
 
-
 
204
See the Writing R Extensions manual for full instructions on converting
-
 
205
package help files to DVI or PDF format.  If you have the necessary tools 
-
 
206
installed,
-
 
207
 
-
 
208
	R CMD rd2dvi --pdf mypkg
-
 
209
	
22
 
210
will use LaTeX to build a PDF version of the reference manual.	
-
 
211
 
-
 
212
 
-
 
213
Debugging
-
 
214
=========
-
 
215
 
-
 
216
See the rw-FAQ.
-
 
217
 
-
 
218
 
-
 
219
Using Visual C++
23
Using Visual C++
220
================
24
================
221
 
25
 
222
You may if you prefer use Visual C++ to make the DLLs (unless they use
26
You may if you prefer use Visual C++ to make the DLLs (unless they use
223
Fortran source!). First build the import library Rdll.lib by
27
Fortran source!). First build the import library Rdll.lib by
Line 311... Line 115...
311
code (Delphi has been one), and this will cause operations such as
115
code (Delphi has been one), and this will cause operations such as
312
0./0. to crash R.  You can re-set the FPU to the correct values by a
116
0./0. to crash R.  You can re-set the FPU to the correct values by a
313
call to the C entry point Rwin_fpset().
117
call to the C entry point Rwin_fpset().
314
 
118
 
315
 
119
 
316
Simple Ports
-
 
317
============
-
 
318
 
-
 
319
If your package has no C nor Fortran nor C++ sources, several steps
-
 
320
can be omitted.
-
 
321
 
-
 
322
You will need 
-
 
323
 
-
 
324
suitable versions of Unix tools including make, sh, rm, sed, awk,
-
 
325
mkdir, echo, cp and cat; we have packaged a set at
-
 
326
http://www.murdoch-sutherland.com/Rtools/tools.zip.
-
 
327
 
-
 
328
perl5, available via http://www.activestate.com/Products/ActivePerl/
-
 
329
 
-
 
330
All of these need to be installed and in your path, and the
-
 
331
appropriate environment variables set.
-
 
332
 
-
 
333
For each package you want to install, unpack it to a directory, say
-
 
334
mypkg, in RHOME\src\library, and run
-
 
335
 
-
 
336
	cd RHOME\src\gnuwin32
-
 
337
	make pkg-mypkg
-
 
338
 
-
 
339
 
-
 
340
Non-standard locations
-
 
341
======================
-
 
342
 
-
 
343
You can specify the location of the package source by PKGDIR and the
-
 
344
library in which to install the package by RLIB, as in
-
 
345
 
-
 
346
	make PKGDIR=/mysources RLIB=/R/library pkg-mypkg
-
 
347
 
-
 
348
which installs the package in \mysources\mypkg as \R\library\mypkg.
-
 
349
 
-
 
350
It may well be simpler to use
-
 
351
 
-
 
352
	R CMD INSTALL -l /R/library /mysources/mypkg
-
 
353
 
-
 
354
Once again, if the paths contain spaces use the short forms, although
-
 
355
R CMD INSTALL will attempt to convert the paths if needed (but they
-
 
356
will need to be quoted on the command line, probably by double
-
 
357
quotes).
-
 
358
 
-
 
359
 
-
 
360
Cross-building packages on Linux
120
Cross-building packages on Linux
361
================================
121
================================
362
 
122
 
363
It is straightforward to build a package on a ix86-linux system,
123
It is straightforward to build a package on a ix86-linux system,
364
although it is not possible (and we have tried, including using WINE)
124
although it is not possible (and we have tried, including using WINE)