fixed indenting
[rrdtool.git] / WIN32-BUILD-TIPS.txt
1 Compiling RRDtool 1.1.x on Win32 with Microsoft Visual C++:
2 ---------------------------------------------------------------
3 5/1/05 Tobi
4 to help windows deal with the reentrant versions of many unix
5 calls link with win32comp.c
6
7 4/10/05 Tobi
8 The windows implementation of strftime does not seem to support
9 the ISO 8601 week number (%V) I have therfore included the file
10 strftime.[ch] which provides strftime_ ... if you compile rrdtool
11 with -Dstrftime=_strftime and link strftime.o then you will
12 get propper support for %V.
13
14 7/29/04 Jake Brutlag
15
16 As of Jan 2004, code for libraries utilized by rrdtool 
17 (png, libart, freetype, and zlib) is no longer distributed with
18 rrdtool. This requires some changes to the compile process on
19 Win32. The solution described here is to compile rrdtool to
20 link against these libraries dynamically. There is an advantage
21 to this approach: namely the rrdtool distribution doesn't have to
22 worry about how to compile these libraries on Win32. In theory,
23 since others already provide and maintain Win32 binaries for these
24 libraries the users don't have to worry about how to compile them
25 either. The disadvantage of this approach is that the DLLs for
26 these libraries must be available on the hosts where rrdtool will run.
27
28 Here are step by step instructions for compiling rrdtool.exe and
29 the perl shared library (RRDS.dll) with Microsoft Visual C++ 6.0.
30 (1) Download libraries rrdtool depends on from GnuWin32:
31 http://gnuwin32.sourceforge.net/
32 For freetype, libpng, and zlib download the "Complete Package"; each of
33 these will be a self-extracting self-installing executable.
34 For libart, download both the "Binaries" and "Developer Files" packages.
35 Unfortunately at this time GnuWin32 doesn't provide the "Complete Package"
36 installer for libart. Perhaps by the time you are following these
37 instructions GnuWin32 will have a "Complete Package" for libart.
38 (2) Install the GnuWin32 libraries by running the executables for freetype,
39 libpng, and zlib. These instructions and the Visual C++ project files
40 distributed with rrdtool assume that you will use the default install
41 location: C:\Program Files\GnuWin32. Extract the two zip files for libart,
42 libart-2.3.3-bin.zip and libart-2.3.3-1-lib.zip into the GnuWin32 directory;
43 the appropriate libart files will be added to the include, lib, and bin
44 subdirectories.
45 (3) Add C:\Program Files\GnuWin32\bin to the PATH (Control Panel ->
46 System -> Advanced -> Environment Variables).
47 (4) Start Microsoft Visual C++ 6.0. Load the workspace file, rrdtool.dsw,
48 from the src subdirectory of your rrdtool code directory.
49 (5) Compile the Release build of the rrdtool project (since rrdtool depends
50 on the rrd project, the rrd library will also be compiled). At this
51 time, the compile will fail in zconf.h, a zlib header file. The problem
52 is a preprocessor directive that loads unistd.h. Open zconf.h in VC++
53 (this file is in C:\Program Files\GnuWin32\include) and find the following
54 code block:
55
56 #if 1           /* HAVE_UNISTD_H -- this line is updated by ./configure */
57 #  include <sys/types.h> /* for off_t */
58 #  include <unistd.h>    /* for SEEK_* and off_t */
59 #  ifdef VMS
60 #    include <unixio.h>   /* for off_t */
61 #  endif
62 #  define z_off_t  off_t
63 #endif 
64
65 Change it to reads as follows (this is code from zlib-1.1.4):
66
67 #if HAVE_UNISTD_H
68 #  include <sys/types.h> /* for off_t */
69 #  include <unistd.h>    /* for SEEK_* and off_t */
70 #  ifdef VMS
71 #    include <unixio.h>   /* for off_t */
72 #  endif
73 #  define z_off_t  off_t
74 #endif 
75
76 Note that it is actually just a one line change. Save the file and
77 recompile rrdtool. By the time you are following these instructions
78 this issue with zconf.h may be resolved.
79 (6) At this point, you can run the executable rrdtool.exe in the
80 src\toolrelease subdirectory. Note that if you wish to run rrdtool
81 on other machines, you will need the following DLLs installed (on the
82 path) on those machines:
83 zlib1.dll
84 libpng12.dll
85 libart_lgpl.dll
86 freetype6.dll
87 msvcrt.dll
88 The names of the first four DLLs might vary from what is listed here
89 depending on the versions of the packages you downloaded from GnuWin32.
90 The fifth DLL, msvcrt.dll, is a system DLL for most versions of Windows.
91 If you are running on old version of Windows, you can install/upgrade to
92 IE4.0 to get this DLL.
93 (7) To compile the perl-shared library, open a Command Prompt (DOS box)
94 and cd to the bindings\perl-shared subdirectory.
95 (8) Run vcvars32.bat; this batch file, in your vc98\bin directory will
96 set necessary environment options for command line compiling.
97 (9) In bindings\perl-shared, run
98 perl ntmake.pl
99 nmake
100 nmake test
101 If nmake test succeeds, you are good to go. RRDs.dll is in 
102 blib\arch\auto\RRDs. If you plan to install via the Active State ppm
103 tool, tar and gzip the blib directory. You can use the RRDs.ppd file
104 in bindings\perl-shared directory. Remember that as in the case of
105 rrdtool.exe you will need the DLLs listed in (6) on the machine where
106 you are going to use RRDs.dll.
107
108 Microsoft Visual C++ 7.1 (.NET 2003):
109
110 Unfortunately, this is more difficult than with VC++ 6.0. The problem
111 is that by default the C runtime dll for VC++ 7.1 is msvcr71.dll rather
112 than msvcrt.dll. The GnuWin32 library binaries are all compiled
113 to use msvcrt.dll and you can't mix msvcr71.dll and msvcrt.dll in the
114 same process. One option is to download the source code for the libraries
115 (available from http://gnuwin32.sourceforge.net) recompile them with
116 VC++ 7.l. Then all the components will use msvcr71.dll. Once you are
117 going to go this route, you can also use static multi-threaded libraries
118 and use static linking between rrdtool (or RRDs.dll) and its dependencies.
119
120 To use the GnuWin32 library binaries, you need to trick VC++ 7.1 into
121 compiling rrdtool to use the older msvcrt.dll. Follow steps (1) - (3)
122 as above, then:
123 (4) Obtain a different version of the msvcrt.lib import library that
124 is compatible with vc7 and points to msvcrt.dll:
125 msvcrtlib_for_vc7.zip from http://xchat.org/win32/testing
126 Backup msvcrt.lib in your vc7\lib directory 
127 (\Program Files\Microsoft Visual Studio .NET 2003\vc7\lib)
128 Then extract the msvcrt.lib from the zip file into the vc7\lib directory.
129 WARNING: Use this msvcrt.lib at your own risk! This is not a Microsoft
130 supplied file nor a file supported by anyone associated with rrdtool.
131 (5) Start Microsoft Visual C++ 7.1. Load the solution file, rrdtool.sln,
132 from the src subdirectory of your rrdtool code directory. Edit zconf.h,
133 as needed, as described under (5) above. Compile the release build of
134 the rrdtool project.
135 Proceed with steps (6) - (9) as above, if you are using/picking up
136 the wrong msvcrt.lib import library then nmake test for perl-shared
137 will fail.
138
139 Note: it is possible in the future that GnuWin32 will provide Win32
140 binaries that utilize msvcr71.dll rather than msvcrt.dll.
141
142 5/14/02 Jake Brutlag
143
144 These notes share some insight I gained compiling 1.1.x with
145 MS Visual C++ 6.0 (using project files). This information may or
146 may not be accurate at the time you are reading this.
147
148 (1) freetype and rrdtool cannot use precompiled headers (which are
149 enabled by default for MSVC++ projects).  MSVC++ 6.0 does not
150 support precompiled headers if #include directives contain MACROS.
151 (2) Compile Release build with Default optimization, not the
152 Maximize Speed optimization. I encountered some strange errors
153 (related to argument processing for complex commands like graph--
154 perhaps the getopt stuff is too blame) with Maximize Speed.
155 (3) libart relies upon config.h (ostensibly generated by the
156 configure script-- but of course not on Win32 platforms). ..\..\confignt
157 (which contains a static Win32 version of config.h) should be on
158 the include path.
159 (4) Fonts are located in the %windir%\fonts, so the default font
160 is c:\winnt\fonts\cour.ttf. (6/19/02) At Kerry Calvert's suggestion
161 this setting was moved to confignt\config.h.
162 (5) libart requires a custom build step to generate art_config.h; this
163 is done manually via the commands:
164 cl -I..\..\confignt gen_art_config.c
165 gen_art_config.exe > art_config.h
166
167 Currently, to compile rrd.lib and rrdtool.exe using
168 the MSVC++ project files, first start MSVC++ 6.0. Open the rrdtool
169 workspace (rrdtool.dsw in the src directory). The active project/
170 configuration should be rrdtool-Win32 Release. Select Rebuild All
171 from the Build menu. The static link library (rrd.lib) will
172 be generated in src\release directory and executable will be generated
173 in the src\toolrelease directory.
174
175 Compiling RRDtool on NT ... work in progress
176 ---------------------------------------------------------------
177                          by Tamas Kovacshazy (khazy@mit.bme.hu)
178
179 Persisting Problems with the current NT port:
180
181 Unfortunately, the RRD perl modules does not work with Perl
182 (ActivePerl) using the current distribution.
183
184 The RRD shared perl module can be compiled after some
185 modification...
186
187 Follow these steps:
188
189 0. Install perl if you do not have it!
190    Visit http://www.ActiveState.com/pw32/ for a complete distribution.
191
192 1. Copy ..\gd1.2\release\gd.lib  to ..\gd1.2\
193 2. Copy ..\src\release\rrd.lib to ..\src
194 3. perl Makefile.pl
195
196 In this step the system complains about something I do not
197 understand. The error message is the following:
198
199 Note (probably harmless): No library found for '-lm'
200
201 Is a library missing? But it does not stop with an error...
202
203 4. nmake test (You must have Visual C++ on the machine!)
204
205 After these steps it generates the test files (svgs and rrds),
206 and they seem to be good.
207
208 The real problem in the shared perl modul is the following:
209
210 I do not know how this installation stuff works. The problem is
211 that the installation stuff looks for the gd.lib and the
212 rrd.lib in the ..\gd1.2 and ..\src directory. The UNIX compile
213 puts the files into these directories, but the NT compile does
214 not.
215
216 It is all for today,
217
218 khazy
219
220 Tamas Kovacshazy  E-mail: khazy@mit.bme.hu  
221 WWW: http://www.mit.bme.hu/~khazy
222 Technical University of Budapest 
223 Department of Measurement and Information Systems
224
225
226 Compiling RRDtool 1.2.x on Win32 with MingW32 gcc:
227 ---------------------------------------------------------------
228
229 1. Obtain and install the current version of the MingW package.
230
231      http://www.mingw.org/download.shtml
232
233    In the MinGW set you will need the gcc and binutils as a minimum.
234
235 2. Obtain either of the following awk versions and install in a directory
236    on your System Path:
237
238    - awk.exe
239
240      http://cm.bell-labs.com/cm/cs/awkbook/index.html
241
242      Note: This version has no dependencies to other libs.
243
244    - gawk.exe  (GnuWin32 version)
245
246      http://gnuwin32.sourceforge.net/packages/gawk.htm
247
248      Note: Also fetch the dependant libraries for it from the same page.
249
250 3. If you plan to create a 'distribution' release of the RRD Tools, the
251    Makefile.Win32 will copy all the needed files to an output directory and
252    then zip the entire directory. A suitable zip utility can be obtained here:
253
254      http://www.info-zip.org/
255
256    Install in a directory on your System Path.
257
258 4. Obtain the following libraries, ideally install them all under a common
259    directory:
260
261    = zlib
262
263      http://oss.oetiker.ch/rrdtool/pub/libs/zlib-1.2.3.tar.gz
264      http://www.zlib.net/
265
266    = libpng
267
268      http://oss.oetiker.ch/rrdtool/pub/libs/libpng-1.2.12.tar.gz
269      http://libpng.sourceforge.net/
270
271    = freetype
272
273      http://oss.oetiker.ch/rrdtool/pub/libs/freetype-2.2.1.tar.gz
274      http://freetype.sourceforge.net/index2.html
275  
276    = libart_lgpl
277
278      http://oss.oetiker.ch/rrdtool/pub/libs/libart_lgpl-2.3.17.tar.gz
279      http://www.levien.com/libart/
280
281      Note: libart_lgpl needs a special tweak because the archive contains
282      only the base directory, but the libart headers are usually included with
283      a directory prefix; therefore create a subfolder 'libart_lgpl' and move
284      all files into this subfolder.
285
286 5. Set up for DOS environment.
287
288    Add MingW\bin and MSYS\bin directories to your System path.
289
290    If the libraries share a common directory set the following environment var:
291
292      set LIBBASE=<shared director>
293      e.g set LIBBASE=C:\Libraries
294
295    If the libraries are scattered, set the following environment vers:
296
297      set ZLIBSDK=<path to zlib>
298      e.g set ZLIBSDK=C:\mytest\zlib-1.2.3
299      set LIBPNG=<path to libpng>
300      set LIBFT2=<path to freetype>
301      set LIBART=<path to libart>
302
303    If using the Gnu Awk (gawk.exe), edit the Makefile.Win32 and change the line:
304
305       AWK       = awk
306
307    to
308
309       AWK       = gawk
310
311 6. Compile the project.
312
313    All dependent libs are statically linked in. This has the benefit that the
314    binaries do not depend on any other DLLs.
315    In order to build the static freetype lib enter the freetype base directory
316    and type 'make'. If everything is fine a message appears that gcc is detected,
317    and that you should again type 'make'. Follow that in order to build freetype.
318    All other libs are build from the sources with the RRDTool Makefile.Win32.
319
320    Switch to the RRDTOOL .\src directory. Then:
321
322       make -f Makefile.Win32 help
323
324    to see the build options, or
325
326       make -f Makefile.Win32 all
327
328    should build the entire package.
329
330 6. Happy Graphing!
331
332
333 written by normw & gk.
334
335