歡迎您光臨本站 註冊首頁

請教Windows下OpenVPN的編譯問題

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

請教Windows下OpenVPN的編譯問題

看論壇上有這個討論,不過好像沒有什麼好的答案。

今天下午搭了一個mingw/msys環境,編譯了一下,完了看見源碼樹下居然有一個叫「Makefile.w32-vc」的文件,再看一下Changlog:



2004.12.12 -- Version 2.0-rc2
* status_open() fixes for MSVC builds (Blaine Fleming).


2004.10.17 -- Version 2.0-beta12
* Source code changes to allow compilation by MSVC

原來早就支持VC了……

我的第一問題是:
如果用VC來編譯,那lzo庫咋辦?還是仍舊用mingw來做??這樣豈不是沒有意義了?

說到lzo,順便請教第二個問題:
我看這些Makefile中的lzo庫的版本是1.08,可是現在我看發行版已經出到2.02了……OpenVPN正式發行的版本用的仍舊是1.08嗎?(偶今天在mingw上整1.08,搞了N次,老是報錯,編譯不過,報什麼不能打開/OUPUT文件之類的,2.02一下子就過了)。
《解決方案》

在win下不熟悉,幫你頂
《解決方案》

《解決方案》

lzo庫可以下載后在win下編譯
openssl也可以直接在win下
可是我編譯到openvpn遇到問題了

以下是編譯輸出:
        cl.exe @C:\DOCUME~1\Admin\LOCALS~1\Temp\nma02344.
cryptoapi.c
cryptoapi.c(84) : error C2143: syntax error : missing ';' before '*'
cryptoapi.c(84) : error C2059: syntax error : '*'
cryptoapi.c(85) : error C2061: syntax error : identifier 'crypt_prov'
cryptoapi.c(85) : error C2059: syntax error : ';'
cryptoapi.c(88) : error C2059: syntax error : '}'
cryptoapi.c(178) : error C2065: 'CAPI_DATA' : undeclared identifier
cryptoapi.c(178) : error C2065: 'cd' : undeclared identifier
cryptoapi.c(178) : error C2059: syntax error : ')'
cryptoapi.c(179) : error C2065: 'HCRYPTHASH' : undeclared identifier
cryptoapi.c(179) : error C2146: syntax error : missing ';' before identifier 'hash'
cryptoapi.c(179) : error C2065: 'hash' : undeclared identifier
cryptoapi.c(180) : error C2275: 'DWORD' : illegal use of this type as an expression
        C:\Program Files\Microsoft Visual Studio\VC98\Include\windef.h(141) : see declaration of 'DWORD'
cryptoapi.c(180) : error C2146: syntax error : missing ';' before identifier 'hash_size'
cryptoapi.c(180) : error C2065: 'hash_size' : undeclared identifier
cryptoapi.c(180) : error C2065: 'len' : undeclared identifier
cryptoapi.c(180) : error C2065: 'i' : undeclared identifier
cryptoapi.c(181) : error C2143: syntax error : missing ';' before 'type'
cryptoapi.c(183) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *'
cryptoapi.c(201) : warning C4013: 'CryptCreateHash' undefined; assuming extern returning int
cryptoapi.c(201) : error C2223: left of '->crypt_prov' must point to struct/union
cryptoapi.c(201) : error C2065: 'CALG_SSL3_SHAMD5' : undeclared identifier
cryptoapi.c(206) : warning C4013: 'CryptGetHashParam' undefined; assuming extern returning int
cryptoapi.c(206) : error C2065: 'HP_HASHSIZE' : undeclared identifier
cryptoapi.c(208) : warning C4013: 'CryptDestroyHash' undefined; assuming extern returning int
cryptoapi.c(216) : warning C4013: 'CryptSetHashParam' undefined; assuming extern returning int
cryptoapi.c(216) : error C2065: 'HP_HASHVAL' : undeclared identifier
cryptoapi.c(223) : error C2065: 'buf' : undeclared identifier
cryptoapi.c(223) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
cryptoapi.c(224) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *'
cryptoapi.c(229) : warning C4013: 'CryptSignHash' undefined; assuming extern returning int
cryptoapi.c(229) : error C2223: left of '->key_spec' must point to struct/union
cryptoapi.c(232) : warning C4022: 'free' : pointer mismatch for actual parameter 1
cryptoapi.c(237) : error C2109: subscript requires array or pointer type
cryptoapi.c(238) : warning C4022: 'free' : pointer mismatch for actual parameter 1
cryptoapi.c(263) : error C2059: syntax error : ')'
cryptoapi.c(265) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *'
cryptoapi.c(267) : error C2223: left of '->crypt_prov' must point to struct/union
cryptoapi.c(267) : error C2223: left of '->free_crypt_prov' must point to struct/union
cryptoapi.c(268) : warning C4013: 'CryptReleaseContext' undefined; assuming extern returning int
cryptoapi.c(268) : error C2223: left of '->crypt_prov' must point to struct/union
cryptoapi.c(269) : error C2223: left of '->cert_context' must point to struct/union
cryptoapi.c(270) : warning C4013: 'CertFreeCertificateContext' undefined; assuming extern returning int
cryptoapi.c(270) : error C2223: left of '->cert_context' must point to struct/union
cryptoapi.c(277) : error C2143: syntax error : missing '{' before '*'
cryptoapi.c(277) : error C2146: syntax error : missing ')' before identifier 'cert_store'
cryptoapi.c(277) : error C2081: 'HCERTSTORE' : name in formal parameter list illegal
cryptoapi.c(277) : error C2061: syntax error : identifier 'cert_store'
cryptoapi.c(277) : error C2059: syntax error : ';'
cryptoapi.c(277) : error C2059: syntax error : ')'
cryptoapi.c(278) : error C2449: found '{' at file scope (missing function header?)
cryptoapi.c(328) : error C2059: syntax error : '}'
error.c
common.h(32) : error C2632: 'long' followed by 'long' is illegal
this compiler appears to lack vararg macros which will cause a significant degradation in efficiency
error.c(476) : error C2065: 'INVALID_SET_FILE_POINTER' : undeclared identifier
error.c(476) : warning C4018: '==' : signed/unsigned mismatch
Generating Code...
《解決方案》

在此之前還有一些頭文件缺少的問題,拷貝了一些cygwin下的過來解決的
《解決方案》

《解決方案》

我的經驗與你分享,在windows下用vc和mingw都可以編譯,但是進行性能測試時發現,100M環境下傳輸ftp大文件,vc編譯的openvpn只能達到3-4MB/s,mingw編譯的openvpn可以達到7-8MB/s。這就是編譯器的差別,請不要用vc來編譯openvpn,呵呵。
《解決方案》

確實是個大問題,沒MINGW的效率高
《解決方案》

原帖由 luna2000 於 2007-8-30 14:37 發表 http://bbs.chinaunix.net/images/common/back.gif
我的經驗與你分享,在windows下用vc和mingw都可以編譯,但是進行性能測試時發現,100M環境下傳輸ftp大文件,vc編譯的openvpn只能達到3-4MB/s,mingw編譯的openvpn可以達到7-8MB/s。這就是編譯器的差別,請不要用 ...

看過一個測試報告,結論相反。
現在搜不到了
《解決方案》

原帖由 cstflying 於 2007-8-24 21:02 發表 http://bbs.chinaunix.net/images/common/back.gif
lzo庫可以下載后在win下編譯
openssl也可以直接在win下
可是我編譯到openvpn遇到問題了

以下是編譯輸出:
        cl.exe @C:\DOCUME~1\Admin\LOCALS~1\Temp\nma02344.
cryptoapi.c
cryptoapi.c(84) : error C ...


在VC2005中編譯OpenVPN項目
1)下載openvpn-2.0.8
2)在VC2005中新建一個控制台空項目
3)把openvpn-2.0.8中的除memcmp.c外的所有文件增加到項目
4)刪除修改config-win32.h文件中的#include <windows.h>行
5)增加openssl的頭文件及庫文件
6)增加lzo的頭文件及庫文件
以上主要是2)及4)其它可參考makefile.w32-vc文件
另最好不要在vc6中編譯,如果要在vc6中編譯要找齊其所用的頭文件及庫文件,比較麻煩

from: http://www.cppblog.com/czh306/archive/2006/09/24/12896.html

[火星人 ] 請教Windows下OpenVPN的編譯問題已經有629次圍觀

http://coctec.com/docs/service/show-post-35192.html