Wireshark-dev: Re: [Wireshark-dev] Problems with epan\oids.c
From: Andrew Hood <ajhood@xxxxxxxxx>
Date: Wed, 19 Mar 2008 23:13:44 +1100
Peter Johansson wrote:
> 2008/3/19, Bill Meier <wmeier@xxxxxxxxxxx <mailto:wmeier@xxxxxxxxxxx>>:
> 
>     Guy Harris wrote:
>     >
>     > If it's not already exported, perhaps the libsmi developers weren't
>     > aware of the wonderful "feature" of the Windows development
>     > environment wherein a library uses the version of the C runtime
>     > library with which it's built rather than the version with which the
>     > application using the library was built; that's a rather alien notion
>     > to most if not all UN*X developers, and I suspect the libsmi
>     > developers started on some UN*X.

They don't really do Windows at all. The Windows version they provide is
compiled with mingw32, and doesn't create a DLL.

>     nicely stated !
> 
>     >
>     > If so, yes, we should probably mention that to them, e.g. on the
>     > libsmi list.
>     >
>     > (While we're at it, we should probably also mention to them that:
>     >
>     >       1) there's an smi_render man page:
>     >
>     >              
>     http://www.ibr.cs.tu-bs.de/cgi-bin/dwww?type=man&location=/usr/local/man/man3/smi_render.3
>     <http://www.ibr.cs.tu-bs.de/cgi-bin/dwww?type=man&location=/usr/local/man/man3/smi_render.3>
>     >
>     >          but there's no link to it in the sidebar on the libsmi
>     home page:
>     >
>     >               http://www.ibr.cs.tu-bs.de/projects/libsmi/
>     >
>     >       2) that page doesn't indicate that the strings returned by those
>     > routines are mallocated.)
> 
> 
>     A quick look at the last several messages on the list indicates that
>     there's been recent changes related to compiling on Windows.
>
>     I'll read thru the messages tomorrow and
>     provide some comments/suggestions as appropriate and as per the above.
> 
>  
> Is it really a good idea to apply the patch where the free(...) calls
> are disabled on Windows?
> The official Wireshark releases for Windows are compiled and linked
> using the same version of MS VC as libsmi was built with (VC6), right?
> Hence this problem *only* affect developers such as myself that use a
> compiler other than MS VC6 on Windows.
> The official releases however will work fine without the proposed patch.
> Since the current code base works and will continue to work even after
> 1.0 for offical releases we have "all the time in the world" to apply a
> long term solution instead. Even if it gets applied after 1.0 has been
> released.
>  
> I would like to see a long term solution where we are able to compile
> every single library using any of the supported tool-chains that is at
> every individual developer's hand. This means that makefiles are
> required (unless anyone sees another solution). I do understand the
> trouble of providing this though. I have tried to compile version 0.4.5,
> 0.4.6 and 0.4.7 of libsmi. Neither compiles "out of the box". 0.4.5 is
> the only candidate that has a chance of compiling on Windows without
> changing the libsmi source code.

There has been some recent discussion of MSVC compiling on the libsmi
mailing list.

libsmi SVN HEAD cross compiles with "LDFLAGS=-lrxspencer" but just about
any other regex libs should work. A later version of mingw32 might not
need this but mine does.

It also compiles with MSVC8 with a small patch.

I will send the attached patch for both of these to Frank and Juergen
for inclusion.

>                                  0.4.6 and 0.4.7 however contain
> includes of Unix-specific header files.

Are any of them in the lib/ directory or just in tools/ ? Wireshark
doesn't use tools/.

The makefile suggested the other day to create smi.dll does not work for
me with MSVC8.

>                                         I thought I should address this
> with the swedes that maintain libsmi but have not got around to it yet.

Swedes? From the names I would guess Frank Strauss, Juergen
Schoenwaelder and many of the other contributors are German or Austrian.
I'm not Swedish either.

-- 
There's no point in being grown up if you can't be childish sometimes.
                -- Dr. Who
Index: win/win.h
===================================================================
--- win/win.h	(revision 7931)
+++ win/win.h	(working copy)
@@ -72,14 +72,4 @@
 #define strtold		strtod
 #endif
 
-/*
- * Some Windows compilers seem to lack strtof() so we fake it here.
- */
-
-#if defined(_MSC_VER)
-#if _MSC_VER <= 1200
-#define strtof(f1,f2) ((float)strtod(f1,f2))
-#endif
-#endif
-
 #endif /* _WIN_H */
Index: win/makefile
===================================================================
--- win/makefile	(revision 7931)
+++ win/makefile	(working copy)
@@ -51,7 +51,7 @@
 cc32	= cl
 CP      = copy
 RM      = del
-MKDIR	= md
+MKDIR	= -mkdir
 
 ##
 ## Definitions:
@@ -113,6 +113,7 @@
 	$(TMPDIR)\dump-sizes.obj		\
 	$(TMPDIR)\dump-svg.obj			\
 	$(TMPDIR)\dump-compliance.obj		\
+	$(TMPDIR)\dump-boilerplate.obj		\
 	$(TMPDIR)\dump-yang.obj			\
 	$(TMPDIR)\fprint.obj			\
 	$(TMPDIR)\rea.obj			\
@@ -138,10 +139,6 @@
 	$(cc32) $(cdebug) $(cflags) $(INCLUDES) \
 		$(DEFINES) -Fo$(TMPDIR)\ $<
 
-{$(ROOT)\winmissing}.c.obj:
-	$(cc32) $(cdebug) $(cflags) $(INCLUDES) \
-		$(DEFINES) -Fo$(TMPDIR)\ $<
-
 
 ##
 ## Targets
@@ -202,7 +199,7 @@
 	$(CP) README.win $(INSTROOT)
 	$(MKDIR) $(INSTROOT)\doc
 	$(CP) ..\doc\*.txt $(INSTROOT)\doc
-	$(CP) ..\doc\*.ps $(INSTROOT)\doc
+	-$(CP) ..\doc\*.ps $(INSTROOT)\doc
 
 install-bin:
 	$(MKDIR) $(BINDIR)
Index: tools/dstring.h
===================================================================
--- tools/dstring.h	(revision 7931)
+++ tools/dstring.h	(working copy)
@@ -21,7 +21,7 @@
 #include <stdarg.h>
 
 #ifdef __GNUC__
-# define inline extern inline
+# define inline /* extern */ static inline
 #else 
 #ifdef HAVE_WIN_H
 # define inline __inline
Index: lib/parser-sming.y
===================================================================
--- lib/parser-sming.y	(revision 7931)
+++ lib/parser-sming.y	(working copy)
@@ -29,6 +29,7 @@
 
 #if defined(_MSC_VER)
 #include <malloc.h>
+#define strtof(f1,f2) ((float)strtod(f1,f2))
 #endif
 
 #ifdef HAVE_WIN_H
Index: configure.in
===================================================================
--- configure.in	(revision 7931)
+++ configure.in	(working copy)
@@ -62,6 +62,15 @@
 
 AC_CHECK_HEADERS(pwd.h unistd.h regex.h stdint.h limits.h)
 
+# In case regex is not in libc
+AC_CHECK_LIB(c,regexec,LDFLAGS="$LDFLAGS",
+[
+    AC_CHECK_LIB(rxspencer,regexec,LDFLAGS="$LDFLAGS -lrxspencer",
+    [
+        AC_CHECK_LIB(regex,regexec,LDFLAGS="$LDFLAGS -lregex")
+    ])
+])
+
 if test "x$prefix" = "xNONE" ; then
   prefix=/usr/local
 fi