### libcurl編譯-windows-x64
文章時間:2020-11-16
網上找了一堆資料,五花八門,幾個文章弄下來才編譯過。這里做一個記錄,也順帶讓想編譯curl庫的朋友,做個借鑒。
首先編譯curl需要 libcurl,openssl,zlib
我放的目錄是 cpps/deps下。

自己可以調整自己所需要的目錄。
libcurl下載地址:https://curl.se/download.html
openssl下載地址:https://www.openssl.org/source/
zlib下載地址:http://www.zlib.net/
需要安裝的軟件都知道 perl,python, NASM 其他什么我就不復數,自行百度吧。

我使用的版本號都是目前最新的。
\
\
首先打開VS命令工具 我這里只編譯64位。所以選擇X64

第一步編譯 zlib
-
進入到zlib 目錄
\
輸入 X64
```
nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"
```
X86
```
nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="inffas32.obj match686.obj"
```
\

編譯好后,進入下一步。
\
\
第二步 編譯openssl
-
同樣進入 openssl目錄

輸入 X64
```
perl Configure VC-WIN64A --prefix=D:\work\code\apiserver\cpps\deps\openssl-1.1.1h\build no-asm
nmake
nmake install
```
X86
```
perl Configure VC-WIN32 --prefix=D:\work\code\apiserver\cpps\deps\openssl-1.1.1h\build no-asm
nmake
nmake install
```
最后可能會有錯誤,提示找不到什么文件,無所謂忽視他。
確定文件夾里面多了一個 build文件夾就可以了 (--prefix= 地址\build)我用的地址+build文件夾 所以是build 換其他文件夾就是其他文件夾名
編譯好,下一步。
\
\
第三步 編譯libcurl
-
編譯好 zlib 與 openssl 后,這里需要把頭文件和lib文件分別拷貝到相應目錄
openssl目錄下:build的include與lib 拷貝到 deps/deps目錄里 (需要手動建立)

zlib目錄下:zconf.h , zlib.h , zutil.h 拷貝到 deps/deps/include里面
zlib.lib zdll.lib 拷貝到 deps/deps/lib 里

\
開始編譯
-
同樣進入 curl目錄 在進入 winbuild

輸入 X64
```
cd winbuild
nmake /f Makefile.vc mode=dll MACHINE=x64 VC=15 ENABLE_IPV6=yes WITH_SSL=dll WITH_ZLIB=dll DEBUG=no
```
X86
```
cd winbuild
nmake /f Makefile.vc mode=dll VC=15 WITH_SSL=dll ENABLE_IPV6=yes WITH_ZLIB=dll DEBUG=no
```
編譯完成后

有個builds文件夾
進入 libcurl-vc15-x64-release-dll-ssl-dll-zlib-dll-ipv6-sspi
分別把include 與 lib拷貝到 deps/deps里面
\
**使用libcurl記得添加宏定義:BUILDING\_LIBCURL;**
(curl我已經添加好了)
\
至此編譯結束。 就可以開始編譯 demo/curl 啦。
尾語: 我覺得編譯就是干貨,網上的文章亂七八糟的。 最后說下 dll 部分 openssl 和 libcurl 都生成了 bin目錄 自己拷貝下dll就好了。zlib在根目錄有個zlib1.dll

****
- 引言
- 目錄
- Get Started
- libcurl編譯-windows-x64-opensll-zlib
- 基礎語法
- if&else
- for&foreach
- while
- function
- 變量
- new
- class
- lambda
- ..字符串拼接
- import
- base
- printf
- printfln
- println
- exit
- sleep&Sleep
- tonumber
- toint
- system
- SetConsoleTitle
- dostring
- dofile
- assert
- _VERSION
- loadlibrary
- freelibrary
- math
- abs
- srand
- rand
- random
- acos
- asin
- atan
- ceil
- cos
- exp
- floor
- fmod
- huge
- log
- max
- maxinteger
- min
- mininteger
- pi
- sin
- sqrt
- tan
- io
- getc
- fopen
- fsize
- fread
- fwrite
- fseek
- fclose
- fflush
- remove
- rename
- getfileext
- getfilepath
- getfilename
- getfilenamenotext
- mkdir
- time
- gettime
- gettimestr
- maketime
- gettickcount
- time2str
- str2time
- issomeday
- getyear
- getmon
- getday
- gethour
- getmin
- getsec
- getyday
- addmonths
- adddays
- addyears
- addweeks
- addhours
- addminutes
- addseconds
- strftime
- string
- find
- rfind
- length
- strlen
- replace
- split
- strcut
- empty
- substr
- npos
- at
- format
- GC
- Collect
- CollectAll
- debug
- open
- close
- breakpoint
- Buffer類
- read
- write
- tostring
- tointerger
- tonumber
- readInt8
- readInt16
- readInt32
- readInt
- readNumber
- readString
- readBool
- writeInt8
- writeInt16
- writeInt32
- writeInt
- writeNumber
- writeString
- writeBool
- seek
- length
- vector類
- push_back
- push_front
- pop_back
- pop_front
- insert
- at
- erase
- pop
- begin
- end
- next
- it
- resize
- clear
- size
- map類
- insert
- find
- erase
- clear
- size
- unordered_map類
- insert
- find
- erase
- pop
- begin
- end
- next
- it
- key
- clear
- size
- 支持庫-模塊
- json
- Get Started
- encode
- encodeT
- decode
- curl
- Get Started
- CURL
- getdata
- getheader
- append
- curl_easy_init
- curl_easy_cleanup
- curl_easy_setopt
- curl_easy_getinfo
- curl_easy_perform
- curl_version
- socket
- server
- setoption
- listen
- run
- send
- closesocket
- stop
- isrunning
- client
- setoption
- run
- connect
- send
- isconnect
- closesocket
- httpserver
- setoption
- listen
- run
- register_handlefunc
- register_controller
- register_controller_default
- stop
- isrunning
- httpserver_request
- addheader
- append
- send
- getparam
- getheader
- geturi
- getpath
- getbuffer
- ServerOption
- ClientOption
- HttpServerOption
- http
- httprequest
- setcookiesfile
- setproxy
- setproxyaccount
- addheaders
- post
- get
- call
- getcookies
- getheaders
- settimeout
- followlocation
- encoding
- encode
- UTF8
- GBK
- hashlib
- md5
- sha1
- sha224
- sha256
- sha384
- sha512
- mysql
- connect
- mysql類
- call
- execute
- error
- isconnect
- clear
- close
- mysql_result
- records
- mysql_record
- fields
- get
- base64
- encode
- decode