[PATCH] Update to build with Visual Studio 2008

"Euphoria Audio" <[email protected]>
Newsgroups gmane.comp.db.rrdtool.devel
Message-ID <06A73B8CBCC02E41B3DEFDF34CB23D589E0F97@exchange01.marlinbroadcasting.com>
Hello All, I love the RRD tool and wanted to use the library in some of my projects but the latest version wouldn't build in VS. I patched the code so it wouldn't affect the other environments and updated the existing VS solution. Let me know if I messed anything up or I should do things a different way. Thank you for your hard work on this!

_______________________________________________
rrd-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
clarsen_vs2008_prj.patch (application/octet-stream, 9.3 KB)
Index: WIN32-BUILD-TIPS.txt
===================================================================
--- WIN32-BUILD-TIPS.txt	(revision 2086)
+++ WIN32-BUILD-TIPS.txt	(working copy)
@@ -1,53 +1,37 @@
 Compiling RRDtool on Win32 with Microsoft Visual C++:
 ---------------------------------------------------------------
+2010-06-04 Chris Larsen [email protected]
 2008-03-12 Stefan Ludewig [email protected]
 
 Here are step by step instructions for building rrdlib.lib and rrdtool.exe
 version 1.3.5 and newer with Microsoft Visual Studio 2008 (9.0.x).
 
-(1) Download and extract libraries rrdtool depends on:
+(1) Create a folder named "contrib" in the directory where this text file is located.
 
-    - cairo:    http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo_1.8.0-1_win32.zip
-      and       http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev_1.8.0-1_win32.zip
+(2) Download the following libraries that rrdtool depends on into this folder:
 
-    - glib:     http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.18/glib_2.18.3-1_win32.zip
-      and       http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.18/glib-dev_2.18.3-1_win32.zip
+    - cairo:    http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo_1.8.10-3_win32.zip 
+      and       http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev_1.8.10-3_win32.zip
 
-    - libpng:   http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libpng_1.2.32-1_win32.zip
-      and       http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libpng-dev_1.2.32-1_win32.zip
+    - glib:     http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.24/glib_2.24.1-1_win32.zip
+      and       http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.24/glib-dev_2.24.1-1_win32.zip
 
-    - libxml2:  http://downloads.sourceforge.net/gnuwin32/libxml2-2.4.12-bin.zip?modtime=1009062000&big_mirror=1
-      and       http://downloads.sourceforge.net/gnuwin32/libxml2-2.4.12-1-lib.zip?modtime=1024783200&big_mirror=1
+    - libpng:   http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libpng_1.4.0-1_win32.zip
+      and       http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libpng-dev_1.4.0-1_win32.zip
 
-    - pango:    http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.22/pango_1.22.2-1_win32.zip
-      and       http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.22/pango-dev_1.22.2-1_win32.zip
+    - libxml2:  http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libxml2_2.7.7-1_win32.zip
+      and       http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libxml2-dev_2.7.7-1_win32.zip
 
-    - zlib: http://www.zlib.net/zlib123-dll.zip
+    - pango:    http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.28/pango_1.28.0-1_win32.zip
+      and       http://ftp.gnome.org/pub/gnome/binaries/win32/pango/1.28/pango-dev_1.28.0-1_win32.zip
 
-(2) Create a folder named "contrib" next to your rrdtool-folder.
+    - zlib:     http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/zlib_1.2.4-2_win32.zip
+      and       http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/zlib-dev_1.2.4-2_win32.zip
 
-(3) Copy the following folders and files from the downloaded archieves into
-    the contrib-folder, you just created:
+(3) Extract all of the .zip files into the contrib folder. Do not extract each library into it's own
+    directory. We want all of the files merged into a structure consisting of "bin, include, lib..."
+    etc folders.
 
-    a) The folder "bin" from cairo_1.8.0-1_win32 and the folders "lib" and
-       "include" from cairo-dev_1.8.0-1_win32 into contrib/cairo.
-
-    b) The folder "bin" from glib_2.18.3-1_win32 and the folders "lib" and
-       "include" from glib-dev_2.18.3-1_win32 into contrib/glib
-
-    c) The folder "bin" from libpng_1.2.32-1_win32 and the folders "lib" and
-       "include" from libpng-dev_1.2.32-1_win32 into contrib/libpng
-
-    d) The file "libxml2.dll" from libxml2-2.4.12-bin/bin and the file
-       "libxml2.lib" from libxml2-2.4.12-1-lib\lib into contrib/libxml2/lib and
-       the folder "include" from from libxml2-2.4.12-1-lib into contrib/libxml2
-
-    e) The folder "bin" from pango_1.22.2-1_win32 and the folders "lib" and
-       "include" from pango-dev_1.22.2-1_win32 into contrib/pango
-
-    f) The folders "lib" and "include" and the file "zlib1.dll" into
-       contrib/zlib
-
 (4) Open the Visual Studio 2008 Solution "rrd.sln" in the win32 folder of
     your rrdtool-folder and build either the project rrdlib (for the
     rrdtool-library), rrdtool (for the rrdtool-executable depending on the
@@ -56,6 +40,10 @@
     executable. These DLLs must be available on all hosts where rrdtool will
     run.
 
+6/10/10 Chris
+Updated project to include latest files and libraries. 
+Builds static or dynamic rrdlib now
+
 5/1/05 Tobi
 to help windows deal with the reentrant versions of many unix
 calls link with win32comp.c
Index: win32/config.h
===================================================================
--- win32/config.h	(revision 2086)
+++ win32/config.h	(working copy)
@@ -5,6 +5,7 @@
 #include <math.h>
 #include <float.h>
 #include <direct.h>
+#include <cctype>
 
 /* realloc does not support NULL as argument */
 
@@ -28,9 +29,9 @@
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
-#define NUMVERS 1.3020
+#define NUMVERS 1.4030
 #define PACKAGE_NAME "rrdtool"
-#define PACKAGE_VERSION "1.3.2"
+#define PACKAGE_VERSION "1.4.3"
 #define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
 
 #define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF)
@@ -54,4 +55,7 @@
 
 /* #define DEBUG 1 */
 
+inline int round(double a) {return int(a + 0.5);}
+//typedef int mode_t;
+
 #endif                          /* CONFIG_H */
Index: win32/rrdlib.vcproj
===================================================================
--- win32/rrdlib.vcproj	(revision 2086)
+++ win32/rrdlib.vcproj	(working copy)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="9.00"
 	Name="rrdlib"
 	ProjectGUID="{CC158E1D-1364-43CA-9B2D-4AF54225C7CA}"
 	RootNamespace="rrdlib"
@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".;../../contrib/cairo/include/cairo;&quot;../../contrib/pango/include/pango-1.0&quot;;&quot;../../contrib/glib/include/glib-2.0&quot;;&quot;../../contrib/glib/lib/glib-2.0/include&quot;;../../contrib/libpng/include;../../contrib/zlib/include;../../contrib/libxml2/include/libxml2"
+				AdditionalIncludeDirectories=".;../contrib/include/cairo;&quot;../contrib/include/pango-1.0&quot;;&quot;../contrib/include/glib-2.0&quot;;&quot;../contrib/lib/glib-2.0/include&quot;;../contrib/include;../contrib/include/libpng12;../contrib/include/libxml2"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -65,7 +65,8 @@
 			<Tool
 				Name="VCLibrarianTool"
 				AdditionalDependencies="cairo.lib pango-1.0.lib pangocairo-1.0.lib libpng.lib zdll.lib glib-2.0.lib gobject-2.0.lib libxml2.lib"
-				AdditionalLibraryDirectories="../../contrib/cairo/lib;../../contrib/pango/lib;../../contrib/glib/lib;../../contrib/libpng/lib;../../contrib/zlib/lib;../../contrib/libxml2/lib"
+				AdditionalLibraryDirectories="../contrib/lib"
+				ModuleDefinitionFile=""
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -281,6 +282,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\src\rrd_utils.c"
+				>
+			</File>
+			<File
 				RelativePath="..\src\rrd_version.c"
 				>
 			</File>
Index: win32/rrdtool.vcproj
===================================================================
--- win32/rrdtool.vcproj	(revision 2086)
+++ win32/rrdtool.vcproj	(working copy)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="9.00"
 	Name="rrdtool"
 	ProjectGUID="{11CD05F8-E5E1-476E-A75F-A112655D4E94}"
 	RootNamespace="rrdtool"
@@ -40,7 +40,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".;../../contrib/cairo/include/cairo;&quot;../../contrib/pango/include/pango-1.0&quot;;&quot;../../contrib/glib/include/glib-2.0&quot;;&quot;../../contrib/glib/lib/glib-2.0/include&quot;;../../contrib/libpng/include;../../contrib/zlib/include;../../contrib/libxml2/include/libxml2"
+				AdditionalIncludeDirectories=""
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -59,7 +59,6 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="rrdlib.lib cairo.lib pango-1.0.lib pangocairo-1.0.lib libpng.lib zdll.lib glib-2.0.lib gobject-2.0.lib libxml2.lib"
 				AdditionalLibraryDirectories="$(ConfigurationName); ../../contrib/cairo/lib;../../contrib/pango/lib;../../contrib/glib/lib;../../contrib/libpng/lib;../../contrib/zlib/lib;../../contrib/libxml2/lib"
 				GenerateDebugInformation="true"
 				TargetMachine="1"
@@ -166,6 +165,10 @@
 		</Configuration>
 	</Configurations>
 	<References>
+		<ProjectReference
+			ReferencedProjectIdentifier="{CC158E1D-1364-43CA-9B2D-4AF54225C7CA}"
+			RelativePathToProject=".\rrdlib.vcproj"
+		/>
 	</References>
 	<Files>
 		<Filter
clarsen_vs2008_src.patch (application/octet-stream, 3 KB)
Index: rrd.h
===================================================================
--- rrd.h	(revision 2086)
+++ rrd.h	(working copy)
@@ -57,6 +57,10 @@
 #ifndef WIN32
 #include <unistd.h>     /* for off_t */
 #else
+#ifdef _MSC_VER
+	typedef int mode_t;
+	#define strtoll _strtoi64 
+#endif
 	typedef size_t ssize_t;
 	typedef long off_t;
 #endif 
Index: rrd_graph.h
===================================================================
--- rrd_graph.h	(revision 2086)
+++ rrd_graph.h	(working copy)
@@ -7,7 +7,11 @@
 
 /* this may configure __EXTENSIONS__ without which pango will fail to compile
    so load this early */
+#ifdef HAVE_CONFIG_H
 #include "../rrd_config.h"
+#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
+#include "../win32/config.h"
+#endif
 
 #include <cairo.h>
 #include <cairo-pdf.h>
Index: rrd_rpncalc.c
===================================================================
--- rrd_rpncalc.c	(revision 2086)
+++ rrd_rpncalc.c	(working copy)
@@ -77,7 +77,7 @@
         return NULL;
     }
     for (i = 0; rpnc[i].op != OP_END; ++i) {
-        rpnp[i].op = rpnc[i].op;
+        rpnp[i].op = (op_en)rpnc[i].op;
         if (rpnp[i].op == OP_NUMBER) {
             rpnp[i].val = (double) rpnc[i].val;
         } else if (rpnp[i].op == OP_VARIABLE || rpnp[i].op == OP_PREV_OTHER) {
Index: rrd_update.c
===================================================================
--- rrd_update.c	(revision 2086)
+++ rrd_update.c	(working copy)
@@ -1548,7 +1548,7 @@
             if (elapsed_pdp_st > 2) {
                 reset_cdp(rrd, elapsed_pdp_st, pdp_temp, last_seasonal_coef,
                           seasonal_coef, rra_idx, ds_idx, cdp_idx,
-                          current_cf);
+                          (cf_en)current_cf);
             }
         }
 
Index: rrd_utils.c
===================================================================
--- rrd_utils.c	(revision 2086)
+++ rrd_utils.c	(working copy)
@@ -25,19 +25,24 @@
 
 #include <assert.h>
 #include <errno.h>
-#include <libgen.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef _MSC_VER
+#include <libgen.h>
 #include <unistd.h>
-
+#endif
 #ifdef WIN32
 #	define random() rand()
 #	define srandom(x) srand(x)
 #	define getpid() 0
 #endif /* WIN32 */
 
+#ifndef S_ISDIR
+#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
+#endif
+
 /* make sure that the random number generator seeded EXACTLY ONCE */
 long rrd_random(void)
 {
@@ -171,7 +176,11 @@
     if (NULL == (pathname_copy = strdup(pathname)))
         return -1;
 
+#ifndef _MSC_VER
     base_dir = dirname(pathname_copy);
+#else
+	_splitpath(pathname_copy, NULL, base_dir, NULL, NULL);
+#endif
 
     if (0 != rrd_mkdir_p(base_dir, mode)) {
         int orig_errno = errno;
@@ -183,8 +192,13 @@
     free(pathname_copy);
 
     /* keep errno as set by mkdir() */
+#ifdef _MSC_VER
+	if (0 != mkdir(pathname))
+        return -1;
+#else
     if (0 != mkdir(pathname, mode))
         return -1;
+#endif
     return 0;
 } /* rrd_mkdir_p */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.