Build OpenVPN from source code in Visual Studio 2008/2013

  1. prepare
    1.  download lzo(lzo-2.09.tar.gz) from here: http://www.oberhumer.com/opensource/lzo/
    2. download openvpn(openvpn-2.3.8.zip) from here: https://openvpn.net/index.php/download/community-downloads.html
    3. download tap-windows6(download as zip) from here: https://github.com/OpenVPN/tap-windows6
    4. you need to download openssl, and compile.
  2. compile
    1. create a empty console project, and delete all .h,.c, change character encoding from unicode to none
    2. drag all .c from lzo to the project
    3. drag all .c from openvpn to the project
    4. set include: openvpn-2.3.8\;openvpn-2.3.8\src\compat\;lzo-2.09\include\;tap-windows6\src\;openvpn-2.3.8\include\
    5. set libraries: libeay32.lib ssleay32.lib ws2_32.lib wininet.lib crypt32.lib iphlpapi.lib winmm.lib
    6.  append preprocessors:
      1. (x64) ;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;NTDDI_VERSION=NTDDI_WINXP;_WIN32_WINNT=_WIN32_WINNT_WINXP;_AMD64_
      2. (x86) ;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;NTDDI_VERSION=NTDDI_WINXP;_WIN32_WINNT=_WIN32_WINNT_WINXP;_USE_32BIT_TIME_T;_X86_
    7. copy config-msvc-version.h.in as config-msvc-version.h, and modify it as this, so that we can use official prebuilt drivers directly :
      1. #define PACKAGE_NAME “openvpn”
        #define PACKAGE_STRING “openvpn 2.3.8”
        #define PACKAGE_TARNAME “openvpn”
        #define PACKAGE “openvpn”
        #define PACKAGE_VERSION “2.3.8”
        #define PRODUCT_BUGREPORT “@PRODUCT_BUGREPORT@”
        #define OPENVPN_VERSION_RESOURCE @PRODUCT_VERSION_RESOURCE@
        #define TAP_WIN_COMPONENT_ID “tap0901”
        #define TAP_WIN_MIN_MAJOR 9
        #define TAP_WIN_MIN_MINOR 21
    8. open config-msvc.h, modify these lines,
      1. // #define ENABLE_DEBUG 1
      2. // #define ENABLE_HTTP_PROXY 1
      3. //#define ENABLE_PKCS11 1
    9. modify project to use /MT (or /MTd if debug build)
    10. time to build
  3. voila! our own build of openvpn is done! no runtime dependence, only single exe file.
  4. what can we do next?
    1. modify the protocol to bypass some firewall, for example, the one in China.
    2. modify the auth to allow more auth type, for example, auth by hardware
  5. last but not the least, backup the current lzo,openvpn,tap-windows7 source code in docs folder of the source code, and submit all into git. we may need to take a look at the original code when we have modified a lot of source code.

13/10/2015

  1. build openvpn-gui from source code
Advertisements

2 Comments

  1. hi my name is wajih and i want to build 2.3.13 latest open with vs 2013 currently i am following your tutorial but i am not getting successful results i am stuck with kindly tell me what i am missing.

    Here are some error screen shots.





    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s