started updating for 1.2 release
[rrdtool.git] / NT-BUILD-TIPS.txt
1 Compiling RRDtool 1.1.x on Win32 with Microsoft Visual C++:
2 ---------------------------------------------------------------
3 4/10/05 Tobi
4 The windows implementation of strftime does not seem to support
5 the ISO 8601 week number (%V) I have therfore included the file
6 strftime.[ch] which provides strftime_ ... if you compile rrdtool
7 with -Dstrftime=_strftime and link strftime.o then you will
8 get propper support for %V.
9
10 7/29/04 Jake Brutlag
11
12 As of Jan 2004, code for libraries utilized by rrdtool 
13 (png, libart, freetype, and zlib) is no longer distributed with
14 rrdtool. This requires some changes to the compile process on
15 Win32. The solution described here is to compile rrdtool to
16 link against these libraries dynamically. There is an advantage
17 to this approach: namely the rrdtool distribution doesn't have to
18 worry about how to compile these libraries on Win32. In theory,
19 since others already provide and maintain Win32 binaries for these
20 libraries the users don't have to worry about how to compile them
21 either. The disadvantage of this approach is that the DLLs for
22 these libraries must be available on the hosts where rrdtool will run.
23
24 Here are step by step instructions for compiling rrdtool.exe and
25 the perl shared library (RRDS.dll) with Microsoft Visual C++ 6.0.
26 (1) Download libraries rrdtool depends on from GnuWin32:
27 http://gnuwin32.sourceforge.net/
28 For freetype, libpng, and zlib download the "Complete Package"; each of
29 these will be a self-extracting self-installing executable.
30 For libart, download both the "Binaries" and "Developer Files" packages.
31 Unfortunately at this time GnuWin32 doesn't provide the "Complete Package"
32 installer for libart. Perhaps by the time you are following these
33 instructions GnuWin32 will have a "Complete Package" for libart.
34 (2) Install the GnuWin32 libraries by running the executables for freetype,
35 libpng, and zlib. These instructions and the Visual C++ project files
36 distributed with rrdtool assume that you will use the default install
37 location: C:\Program Files\GnuWin32. Extract the two zip files for libart,
38 libart-2.3.3-bin.zip and libart-2.3.3-1-lib.zip into the GnuWin32 directory;
39 the appropriate libart files will be added to the include, lib, and bin
40 subdirectories.
41 (3) Add C:\Program Files\GnuWin32\bin to the PATH (Control Panel ->
42 System -> Advanced -> Environment Variables).
43 (4) Start Microsoft Visual C++ 6.0. Load the workspace file, rrdtool.dsw,
44 from the src subdirectory of your rrdtool code directory.
45 (5) Compile the Release build of the rrdtool project (since rrdtool depends
46 on the rrd project, the rrd library will also be compiled). At this
47 time, the compile will fail in zconf.h, a zlib header file. The problem
48 is a preprocessor directive that loads unistd.h. Open zconf.h in VC++
49 (this file is in C:\Program Files\GnuWin32\include) and find the following
50 code block:
51
52 #if 1           /* HAVE_UNISTD_H -- this line is updated by ./configure */
53 #  include <sys/types.h> /* for off_t */
54 #  include <unistd.h>    /* for SEEK_* and off_t */
55 #  ifdef VMS
56 #    include <unixio.h>   /* for off_t */
57 #  endif
58 #  define z_off_t  off_t
59 #endif 
60
61 Change it to reads as follows (this is code from zlib-1.1.4):
62
63 #if HAVE_UNISTD_H
64 #  include <sys/types.h> /* for off_t */
65 #  include <unistd.h>    /* for SEEK_* and off_t */
66 #  ifdef VMS
67 #    include <unixio.h>   /* for off_t */
68 #  endif
69 #  define z_off_t  off_t
70 #endif 
71
72 Note that it is actually just a one line change. Save the file and
73 recompile rrdtool. By the time you are following these instructions
74 this issue with zconf.h may be resolved.
75 (6) At this point, you can run the executable rrdtool.exe in the
76 src\toolrelease subdirectory. Note that if you wish to run rrdtool
77 on other machines, you will need the following DLLs installed (on the
78 path) on those machines:
79 zlib1.dll
80 libpng12.dll
81 libart_lgpl.dll
82 freetype6.dll
83 msvcrt.dll
84 The names of the first four DLLs might vary from what is listed here
85 depending on the versions of the packages you downloaded from GnuWin32.
86 The fifth DLL, msvcrt.dll, is a system DLL for most versions of Windows.
87 If you are running on old version of Windows, you can install/upgrade to
88 IE4.0 to get this DLL.
89 (7) To compile the perl-shared library, open a Command Prompt (DOS box)
90 and cd to the bindings\perl-shared subdirectory.
91 (8) Run vcvars32.bat; this batch file, in your vc98\bin directory will
92 set necessary environment options for command line compiling.
93 (9) In bindings\perl-shared, run
94 perl ntmake.pl
95 nmake
96 nmake test
97 If nmake test succeeds, you are good to go. RRDs.dll is in 
98 blib\arch\auto\RRDs. If you plan to install via the Active State ppm
99 tool, tar and gzip the blib directory. You can use the RRDs.ppd file
100 in bindings\perl-shared directory. Remember that as in the case of
101 rrdtool.exe you will need the DLLs listed in (6) on the machine where
102 you are going to use RRDs.dll.
103
104 Microsoft Visual C++ 7.1 (.NET 2003):
105
106 Unfortunately, this is more difficult than with VC++ 6.0. The problem
107 is that by default the C runtime dll for VC++ 7.1 is msvcr71.dll rather
108 than msvcrt.dll. The GnuWin32 library binaries are all compiled
109 to use msvcrt.dll and you can't mix msvcr71.dll and msvcrt.dll in the
110 same process. One option is to download the source code for the libraries
111 (available from http://gnuwin32.sourceforge.net) recompile them with
112 VC++ 7.l. Then all the components will use msvcr71.dll. Once you are
113 going to go this route, you can also use static multi-threaded libraries
114 and use static linking between rrdtool (or RRDs.dll) and its dependencies.
115
116 To use the GnuWin32 library binaries, you need to trick VC++ 7.1 into
117 compiling rrdtool to use the older msvcrt.dll. Follow steps (1) - (3)
118 as above, then:
119 (4) Obtain a different version of the msvcrt.lib import library that
120 is compatible with vc7 and points to msvcrt.dll:
121 msvcrtlib_for_vc7.zip from http://xchat.org/win32/testing
122 Backup msvcrt.lib in your vc7\lib directory 
123 (\Program Files\Microsoft Visual Studio .NET 2003\vc7\lib)
124 Then extract the msvcrt.lib from the zip file into the vc7\lib directory.
125 WARNING: Use this msvcrt.lib at your own risk! This is not a Microsoft
126 supplied file nor a file supported by anyone associated with rrdtool.
127 (5) Start Microsoft Visual C++ 7.1. Load the solution file, rrdtool.sln,
128 from the src subdirectory of your rrdtool code directory. Edit zconf.h,
129 as needed, as described under (5) above. Compile the release build of
130 the rrdtool project.
131 Proceed with steps (6) - (9) as above, if you are using/picking up
132 the wrong msvcrt.lib import library then nmake test for perl-shared
133 will fail.
134
135 Note: it is possible in the future that GnuWin32 will provide Win32
136 binaries that utilize msvcr71.dll rather than msvcrt.dll.
137
138 5/14/02 Jake Brutlag
139
140 These notes share some insight I gained compiling 1.1.x with
141 MS Visual C++ 6.0 (using project files). This information may or
142 may not be accurate at the time you are reading this.
143
144 (1) freetype and rrdtool cannot use precompiled headers (which are
145 enabled by default for MSVC++ projects).  MSVC++ 6.0 does not
146 support precompiled headers if #include directives contain MACROS.
147 (2) Compile Release build with Default optimization, not the
148 Maximize Speed optimization. I encountered some strange errors
149 (related to argument processing for complex commands like graph--
150 perhaps the getopt stuff is too blame) with Maximize Speed.
151 (3) libart relies upon config.h (ostensibly generated by the
152 configure script-- but of course not on Win32 platforms). ..\..\confignt
153 (which contains a static Win32 version of config.h) should be on
154 the include path.
155 (4) Fonts are located in the %windir%\fonts, so the default font
156 is c:\winnt\fonts\cour.ttf. (6/19/02) At Kerry Calvert's suggestion
157 this setting was moved to confignt\config.h.
158 (5) libart requires a custom build step to generate art_config.h; this
159 is done manually via the commands:
160 cl -I..\..\confignt gen_art_config.c
161 gen_art_config.exe > art_config.h
162
163 Currently, to compile rrd.lib and rrdtool.exe using
164 the MSVC++ project files, first start MSVC++ 6.0. Open the rrdtool
165 workspace (rrdtool.dsw in the src directory). The active project/
166 configuration should be rrdtool-Win32 Release. Select Rebuild All
167 from the Build menu. The static link library (rrd.lib) will
168 be generated in src\release directory and executable will be generated
169 in the src\toolrelease directory.
170
171 Compiling RRDtool on NT ... work in progress
172 ---------------------------------------------------------------
173                          by Tamas Kovacshazy (khazy@mit.bme.hu)
174
175 Persisting Problems with the current NT port:
176
177 Unfortunately, the RRD perl modules does not work with Perl
178 (ActivePerl) using the current distribution.
179
180 The RRD shared perl module can be compiled after some
181 modification...
182
183 Follow these steps:
184
185 0. Install perl if you do not have it!
186    Visit http://www.ActiveState.com/pw32/ for a complete distribution.
187
188 1. Copy ..\gd1.2\release\gd.lib  to ..\gd1.2\
189 2. Copy ..\src\release\rrd.lib to ..\src
190 3. perl Makefile.pl
191
192 In this step the system complains about something I do not
193 understand. The error message is the following:
194
195 Note (probably harmless): No library found for '-lm'
196
197 Is a library missing? But it does not stop with an error...
198
199 4. nmake test (You must have Visual C++ on the machine!)
200
201 After these steps it generates the test files (svgs and rrds),
202 and they seem to be good.
203
204 The real problem in the shared perl modul is the following:
205
206 I do not know how this installation stuff works. The problem is
207 that the installation stuff looks for the gd.lib and the
208 rrd.lib in the ..\gd1.2 and ..\src directory. The UNIX compile
209 puts the files into these directories, but the NT compile does
210 not.
211
212 It is all for today,
213
214 khazy
215
216 Tamas Kovacshazy  E-mail: khazy@mit.bme.hu  
217 WWW: http://www.mit.bme.hu/~khazy
218 Technical University of Budapest 
219 Department of Measurement and Information Systems