[stunnel-users] patch to build stunnel 4.15 with VS2005

David Gillingham dgillingham+stunnel at gmail.com
Wed Jun 28 18:14:16 CEST 2006


All--

I have created a patch that will allow stunnel 4.15 to be built with
Visual Studio 2005's command line environment.  I have only tested it
with VS2k5, but it should work for all Visual Studio .NET versions
(that is, VS 7.0 or later).

After you apply this patch to the source tree, you will need to run
the makefile from a Visual Studio Command prompt
(Start->Programs->Visual Studio->Visual Studio Tools->Visual Studio
Command Prompt).  From there, change the working directory to the
stunnel\src folder and execute the command "nmake -f vs.mak all".
After the build process has completed, you will have a working
stunnel.exe.

This patch will modify vc.mak to a working makefile for nmake
(mimicing the basic structure of mingw.mak), common.h to include a
couple missing headers for the I/O functions in pty.c, and env.c to
include the winsock headers under the Win32 environment (replicating
how it was done in common.h).

This patch that is a result of internal testing/development I've done
here at work and am releasing it to this list (and the stunnel
developers) so that these changes could possibly be included in future
stunnel releases.  To the stunnel devs: if there's any additional work
that can be done to get this integrated by the next release, just
mention it.

The other day, I tried sending the patch to the list as an attachment,
but my message never showed up on either the mirt.net or google groups
mirrors.  I can only assume it was rejected because of the attachment.
 What follows is the full text of my patch file.

> cat 4.15-MSVC2005.patch
diff -cr stunnel-4.15-orig/src/common.h stunnel-4.15/src/common.h
*** stunnel-4.15-orig/src/common.h	Fri Mar 10 08:54:56 2006
--- stunnel-4.15/src/common.h	Fri Jun 23 21:41:00 2006
***************
*** 153,158 ****
--- 153,164 ----
  #endif
  #include <windows.h>

+ /* include Visual Studio headers needed for I/O manipulation */
+ #ifdef _MSC_VER
+ #include <io.h>
+ #include <fcntl.h>
+ #endif
+
  #define ECONNRESET WSAECONNRESET
  #define ENOTSOCK WSAENOTSOCK
  #define ENOPROTOOPT WSAENOPROTOOPT
diff -cr stunnel-4.15-orig/src/env.c stunnel-4.15/src/env.c
*** stunnel-4.15-orig/src/env.c	Sat Jan  7 13:47:36 2006
--- stunnel-4.15/src/env.c	Mon Jun 26 21:11:25 2006
***************
*** 31,45 ****
  /* getpeername() can't be declared in the following includes */
  #define getpeername no_getpeername
  #include <sys/types.h>
  #include <sys/socket.h> /* for AF_INET */
  #include <netinet/in.h>
  #include <arpa/inet.h>  /* for inet_addr() */
  #include <stdlib.h>     /* for getenv() */
  #ifdef __BEOS__
  #include <be/bone/arpa/inet.h> /* for AF_INET */
  #include <be/bone/sys/socket.h> /* for AF_INET */
- #else
- #include <sys/socket.h> /* for AF_INET */
  #endif
  #undef getpeername

--- 31,52 ----
  /* getpeername() can't be declared in the following includes */
  #define getpeername no_getpeername
  #include <sys/types.h>
+ #ifdef USE_WIN32
+ #ifdef _WIN32_WCE
+ #include <winsock.h>
+ #else
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+ #endif /* _WIN32_WCE */
+ #else /* USE_WIN32 */
  #include <sys/socket.h> /* for AF_INET */
  #include <netinet/in.h>
  #include <arpa/inet.h>  /* for inet_addr() */
+ #endif /* USE_WIN32 */
  #include <stdlib.h>     /* for getenv() */
  #ifdef __BEOS__
  #include <be/bone/arpa/inet.h> /* for AF_INET */
  #include <be/bone/sys/socket.h> /* for AF_INET */
  #endif
  #undef getpeername

diff -cr stunnel-4.15-orig/src/vc.mak stunnel-4.15/src/vc.mak
*** stunnel-4.15-orig/src/vc.mak	Sat Jan 21 10:17:32 2006
--- stunnel-4.15/src/vc.mak	Tue Jun 27 21:02:15 2006
***************
*** 1,2 ****
! # makefile for VC is not ready...

--- 1,45 ----
! # Simple Makefile.w32 for stunnel.exe by Michal Trojnara 1998-2006
! #
! # Modified by David Gillingham (dgillingham at gmail.com) for Visual
! # Studio
!
! # Modify this to point to your actual openssl compile directory
! # (You did already compile openssl, didn't you???)
! SSLDIR=..\..\openssl-0.9.7j
!
! DEFINES=-DUSE_WIN32 -D_CRT_SECURE_NO_DEPRECATE \
! 	-D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_GETADDRINFO \
! 	-DHAVE_GETNAMEINFO -D_MBCS
! CC=cl
! CFLAGS=-MD -W3 -Ox -O2 -Ob2 -Gs0 -GF -Gy -GL -nologo \
! 	-I"$(SSLDIR)\inc32" $(DEFINES)
!
! LINK=link
! LDFLAGS=-INCREMENTAL:NO -NOLOGO -SUBSYSTEM:WINDOWS -OPT:REF \
! 	-OPT:ICF -LTCG -MACHINE:X86 -ERRORREPORT:PROMPT
! LIBS=-LIBPATH:"$(SSLDIR)\out32dll" wsock32.lib ssleay32.lib \
! 	libeay32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib \
! 	advapi32.lib
!
! OBJS=stunnel.obj ssl.obj ctx.obj file.obj client.obj protocol.obj \
! 	sthreads.obj log.obj options.obj network.obj resolver.obj \
! 	gui.obj
!
!
! all: stunnel.exe
!
! clean:
! 	del $(OBJS) resources.res
! 	del *.manifest
! 	del stunnel.exe
!
! stunnel.exe: $(OBJS) resources.res
! 	$(LINK) $(LDFLAGS) $(LIBS) -OUT:$@ $**
! 	IF EXIST $@.manifest mt -manifest $@.manifest -outputresource:$@;1
!
! resources.res: resources.rc resources.h stunnel.ico
! 	rc /fo $@ resources.rc
!
! $(OBJS): $*.c *.h
! 	$(CC) $(CFLAGS) -c $*.c



More information about the stunnel-users mailing list