libcurl在windows上编译

libcurl在windows上编译


本文参考:

1) MinGW32和64位交叉编译环境的安装和使用

http://blog.csdn.net/ubuntu64fan/article/details/8918808

2) Windows7下使用mingw编译openssl

http://blog.csdn.net/ubuntu64fan/article/details/49865237


1 编译32位libcurl

编译准备工作:使用MingW编译32位的下列动态库和静态库。

进入MSYS-x64-Shell, 运行:

$ source /local32/etc/profile.local

编辑: /local32/etc/profile.local,增加下面4行(ZLIB_, OPENSSL_, LIBSSH2_, LIBCURL_):

# Configure PATH and FLAGS.
...

APPLICATION_ARRAY=(
...
"ZLIB_PREFIX:$DST_DIR/zlib"
"OPENSSL_PREFIX:$DST_DIR/openssl"
"LIBSSH2_PREFIX:$DST_DIR/libssh2"
"LIBCURL_PREFIX:$DST_DIR/libcurl"
)

$ source /local32/etc/profile.local

$ cd $SRC_DIR

1.1 zlib

/local32/src/zlib-1.2.8 $ 1 make -f win32/Makefile.gcc clean
/local32/src/zlib-1.2.8 $ 1 export "INCLUDE_PATH=$ZLIB_PREFIX/include"
/local32/src/zlib-1.2.8 $ 1 export "LIBRARY_PATH=$ZLIB_PREFIX/lib"
/local32/src/zlib-1.2.8 $ 1 export "BINARY_PATH=$ZLIB_PREFIX/bin"
/local32/src/zlib-1.2.8 $ make -f win32/Makefile.gcc SHARED_MODE=1 install

1.2 openssl

/local32/src/openssl-1.0.2e $ ./config shared --prefix=$OPENSSL_PREFIX
/local32/src/openssl-1.0.2e $ make -j 4 
/local32/src/openssl-1.0.2e $ make test
/local32/src/openssl-1.0.2e $ make install

1.3 libssh2

/local32/src/libssh2-1.8.0 $ sh ./configure --prefix=$LIBSSH2_PREFIX --with-libz-prefix=$ZLIB_PREFIX --with-libssl-prefix=$OPENSSL_PREFIX
/local32/src/libssh2-1.8.0 $ make
/local32/src/libssh2-1.8.0 $ make install

 version: 1.8.0

 Host type:        i686-pc-mingw32
 Install prefix:   /local32/dst/libssh2
 Compiler:         gcc
 Compiler flags:   -I/local32/dst/libssh2/include -I/local32/
 -I/local32/dst/libusbx/include -I/local32/dst/boost/include
nclude -I/local32/dst/gettext/include -I/local32/dst/pkg-conf
dst/botan/include -I/local32/dst/fftw/include -I/local32/dst/
-I/local32/dst/libxml2/include -I/local32/dst/libtool/include
e=pentium3 -DLIBSSH2_WIN32
 Library types:    Shared=yes, Static=yes
 Crypto library:   OpenSSL (AES-CTR: yes)
 Clear memory:     unsupported
 Debug build:      no
 Build examples:   yes
 Path to sshd:      (only for self-tests)
 zlib compression: yes

1.4 curl and libcurl

/local32/src $ wget https://curl.haxx.se/download/curl-7.53.1.tar.gz
...
/local32/src/curl-7.53.1 $ sh ./configure --prefix=$LIBCURL_PREFIX
/local/src/curl-7.53.1 $ make
/local64/src/curl-7.53.1 $ make install


2 编译64位libcurl

编译准备工作:使用MingW编译64位的下列动态库和静态库:

进入MSYS-x64-Shell, 运行:


$ source /local64/etc/profile.local

编辑:/local64/etc/profile.local,增加下面4行(ZLIB_, OPENSSL_, LIBSSH2_, LIBCURL_):

# Configure PATH and FLAGS.
...

APPLICATION_ARRAY=(
...
"ZLIB_PREFIX:$DST_DIR/zlib"
"OPENSSL_PREFIX:$DST_DIR/openssl"
"LIBSSH2_PREFIX:$DST_DIR/libssh2"
"LIBCURL_PREFIX:$DST_DIR/libcurl"
)

$ source /local64/etc/profile.local

$ cd $SRC_DIR

2.1 zlib

/local64/src/zlib-1.2.8 $ 1 make -f win32/Makefile.gcc clean
/local64/src/zlib-1.2.8 $ 1 export "INCLUDE_PATH=$ZLIB_PREFIX/include"
/local64/src/zlib-1.2.8 $ 1 export "LIBRARY_PATH=$ZLIB_PREFIX/lib"
/local64/src/zlib-1.2.8 $ 1 export "BINARY_PATH=$ZLIB_PREFIX/bin"
/local64/src/zlib-1.2.8 $ make -f win32/Makefile.gcc SHARED_MODE=1 install

2.2 openssl

/local64/src/openssl-1.0.2e $ perl Configure mingw64 shared --prefix=$OPENSSL_PREFIX
/local64/src/openssl-1.0.2e $ make -j 4 
/local64/src/openssl-1.0.2e $ make test
/local64/src/openssl-1.0.2e $ make install

2.3 libssh2

/local64/src/libssh2-1.8.0 $ sh ./configure --prefix=$LIBSSH2_PREFIX --with-libz-prefix=$ZLIB_PREFIX --with-libssl-prefix=$OPENSSL_PREFIX
/local64/src/libssh2-1.8.0 $ make
/local64/src/libssh2-1.8.0 $ make install

2.4 curl and libcurl

/local64/src $ wget https://curl.haxx.se/download/curl-7.53.1.tar.gz
...
/local64/src/curl-7.53.1 $ sh ./configure --prefix=$LIBCURL_PREFIX
/local64/src/curl-7.53.1 $ make
/local64/src/curl-7.53.1 $ make install

3 测试

/local64/dst/libcurl/bin$ ./curl.exe -V
curl 7.53.1 (i686-pc-mingw32) libcurl/7.53.1 OpenSSL/1.0.2e zlib/1.2.8 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: IPv6 Largefile NTLM SSL libz TLS-SRP HTTPS-proxy 



你可能感兴趣的:(c)