« | July 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | |
| 公告 |
戒除浮躁,读好书,交益友 |
Blog信息 |
blog名称:邢红瑞的blog 日志总数:523 评论数量:1142 留言数量:0 访问次数:9674074 建立时间:2004年12月20日 |

| |
[c++]vc9编译openvpn2.2.1 原创空间, 文章收藏, 随笔, 软件技术, 电脑与网络
邢红瑞 发表于 2011/11/14 14:44:39 |
先安装python2.7,主要不是3.0.python3和2的差别很大。最好使用vc9,使用vc10会麻烦一些,并且安装Windows SDK 7。在c盘根目录下建立openvpn-build目录,然后下载openvpn-2.2.1。将openssl目录,lzo目录,pkcs11-helper目录 copy到openvpn-build目录下。修改C:\openvpn-build\openvpn-2.2.1\win目录下的settings.in文件。# Version numbers, settings, and dependencies# for Windows OpenVPN installer.## Note that some variables are parsed by wb.py from version.m4 and are not # stored in this file. This is done to allow using the old and new Windows build # systems side-by-side
# Features to include. DO NOT comment these out, use 1 to enable and 0 to# disable.!define ENABLE_PASSWORD_SAVE 1
# ENABLE_CLIENT_SERVER enables the point-to-multipoint support. Normally you# want to have this enabled.!define ENABLE_CLIENT_SERVER 1
# ENABLE_CLIENT_ONLY removes server-side point-to-multipoint features. This# depends on ENABLE_CLIENT_SERVER being set to 1.!define ENABLE_CLIENT_ONLY 0
!define ENABLE_MANAGEMENT 1!define ENABLE_HTTP_PROXY 1!define ENABLE_SOCKS 1!define ENABLE_FRAGMENT 1!define ENABLE_DEBUG 1
# Branding!define PRODUCT_NAME "OpenVPN"!define PRODUCT_UNIX_NAME "openvpn"!define PRODUCT_FILE_EXT "ovpn"
# Include the OpenVPN GUI exe in the installer. Comment out USE_GUI to disable.!define USE_GUI!define OPENVPN_GUI_DIR "../openvpn-gui"!define OPENVPN_GUI "openvpn-gui-1.0.3.exe"
# Prebuilt libraries. DMALLOC is optional.!define OPENSSL_DIR "./openssl"!define LZO_DIR "./lzo"!define PKCS11_HELPER_DIR "./pkcs11-helper"
# write output files here!define DIST "dist"
# tapinstall.exe (a.k.a. devcon.exe) source code. Not needed if DRVBINSRC is # defined (or if using pre-built mode).!define TISRC "../tapinstall"
# TAP adapter icon -- visible=0x81 or hidden=0x89!define PRODUCT_TAP_CHARACTERISTICS 0x81
# TAP adapter metadata. Version information in ../version.m4.!define PRODUCT_TAP_RELDATE "04/19/2010"!define PRODUCT_TAP_DEVICE_DESCRIPTION "TAP-Win32 Adapter V9"!define PRODUCT_TAP_PROVIDER "TAP-Win32 Provider V9"
# Build debugging version of TAP driver;!define PRODUCT_TAP_DEBUG
# Build debugging version of openvpn.exe;!define PRODUCT_OPENVPN_DEBUG
# DDK path -- currently Windows 7 WDK!define DDK_PATH "c:/winddk/7600.16385.1";!define DDK_PATH "c:/winddk/6001.18002"
# output path for tap_span.py!define TAP_DIST "tap_dist"
# Visual studio path!define MSVC "C:/Program Files/Microsoft Visual Studio 9.0"
# Visual studio C run-time library path!define MSVC_CRT "../Microsoft.VC90.CRT"
# Code Signing.# If undefined, don't sign any files.!define SIGNTOOL "../signtool"!define PRODUCT_SIGN_CN "openvpn"
# Directory with prebuilt TAP drivers and tapinstall.exes!define TAP_PREBUILT "../tap-prebuilt"
; DEBUGGING -- set to something like "-DBG2"!define OUTFILE_LABEL ""
; DEBUGGING -- set to something like "DEBUG2"!define TITLE_LABEL ""
然后打开Visual Studio 2008 命令提示,运行 python build_exe.py,编译出openvpn.exe.如果使用ide进行编译,现在工具->选项,项目和解决方案中vc++目录中添加openssl lzo pkcs11-helper的include和lib 路径。在项目菜单->openvpn属性中 配置属性->c/c++中预处理器属性页 预处理器定义添加 WIN32_LEAN_AND_MEAN;_MBCS;_CRT_SECURE_NO_DEPRECATE,在项目菜单->openvpn属性中 配置属性->连接器 输入中 附加依赖项 加入 libeay32.lib ssleay32.lib lzo2.lib crypt32.lib iphlpapi.lib ws2_32.lib wininet.lib。然后编译即可。
需要注意的是 命令行编译的没有问题,但是vc ide 编译的,运行时出现
出现 Mon Nov 21 17:30:51 2011 us=760000 Error opening registry key: SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}Mon Nov 21 17:30:51 2011 us=760000 ExitingMon Nov 21 17:30:51 2011 us=760000 Closing Win32 semaphore 'openvpn_netcmd'
查看代码
RegOpenKeyEx 返回2 ,通过
DWORD dwError=0; char szError[256]={0}; status = RegOpenKeyEx( HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &adapter_key); dwError = GetLastError(); FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, 0, 0, szError, sizeof(szError), NULL);
看不出任何错误,桂杰提示说 是不是双字节啊,我想了一下 openvpn编译
openvpn属性 配置属性 ->常规 中项目默认值 选择 使用多字节字符集。 |
|
|