Difference between revisions of "Curl on Windows"

From D Wiki
Jump to: navigation, search
(MinGW fix)
(Update curl-7.36.0)
Line 1: Line 1:
 
==Building libcurl on Windows==
 
==Building libcurl on Windows==
 
As of curl-7.35.0 please apply the following patches.
 
# http://curl.haxx.se/mail/lib-2014-02/0003.html
 
# <strike>http://curl.haxx.se/mail/lib-2014-02/0097.html</strike>
 
# http://curl.haxx.se/mail/lib-2014-02/0118.html
 
This works with dmd 2.065 beta 3. It does not work with dmd 2.064.
 
  
 
===Required tools===
 
===Required tools===
Line 26: Line 20:
 
===Building libcurl 32 bit===
 
===Building libcurl 32 bit===
 
# Create directory C:\BUILD
 
# Create directory C:\BUILD
# Download curl-7.33.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD
+
# Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD
 
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD
 
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD
 
# Save the following batch file as C:\BUILD\build-curl32.bat
 
# Save the following batch file as C:\BUILD\build-curl32.bat
Line 42: Line 36:
  
 
:: Delete object files from previous build
 
:: Delete object files from previous build
del /S zlib-1.2.8\*.o curl-7.33.0\*.o curl-7.33.0\*.res
+
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res
  
 
cd zlib-1.2.8
 
cd zlib-1.2.8
Line 48: Line 42:
 
cd ..
 
cd ..
  
cd curl-7.33.0
+
cd curl-7.36.0
 
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static
 
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static
 
strip -s lib\libcurl.dll
 
strip -s lib\libcurl.dll
Line 65: Line 59:
 
===Building libcurl 64 bit===
 
===Building libcurl 64 bit===
 
# Create directory C:\BUILD
 
# Create directory C:\BUILD
# Download curl-7.33.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD
+
# Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD
 
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD
 
# Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD
 
# Save the following batch file as C:\BUILD\build-curl64.bat
 
# Save the following batch file as C:\BUILD\build-curl64.bat
Line 82: Line 76:
  
 
:: Delete object files from previous build
 
:: Delete object files from previous build
del /S zlib-1.2.8\*.o curl-7.33.0\*.o curl-7.33.0\*.res
+
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res
  
 
cd zlib-1.2.8
 
cd zlib-1.2.8
Line 88: Line 82:
 
cd ..
 
cd ..
  
cd curl-7.33.0
+
cd curl-7.36.0
 
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static
 
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static
 
strip -s lib\libcurl.dll
 
strip -s lib\libcurl.dll

Revision as of 00:44, 27 March 2014

Building libcurl on Windows

Required tools

import std.net.curl;
import std.stdio;

void main()
{
	writeln(get("https://google.com/"));
}

Building libcurl 32 bit

  1. Create directory C:\BUILD
  2. Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD
  3. Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD
  4. Save the following batch file as C:\BUILD\build-curl32.bat
  5. Run build-curl32 from Windows command prompt
@echo off

:: 1) Path to MinGW\bin
:: 2) Path to Digital Mars's implib.exe
SET PATH=C:\Dev\MinGW\bin;C:\Dev\dm\bin;
SET ZLIB_PATH=C:\BUILD\zlib-1.2.8
SET INSTALL_DIR=C:\D\dmd2\windows
:: ---------------------------------------------------------------

:: Delete object files from previous build
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res

cd zlib-1.2.8
mingw32-make -fwin32/Makefile.gcc
cd ..

cd curl-7.36.0
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static
strip -s lib\libcurl.dll

mkdir %INSTALL_DIR%\bin %INSTALL_DIR%\lib
copy lib\libcurl.dll %INSTALL_DIR%\bin
implib /system %INSTALL_DIR%\lib\curl.lib lib\libcurl.dll
cd ..

:: Build sample
SET PATH=%INSTALL_DIR%\bin
dmd app.d -ofapp32.exe
app32

Building libcurl 64 bit

  1. Create directory C:\BUILD
  2. Download curl-7.36.0.zip from http://curl.haxx.se/download.html and extract it into C:\BUILD
  3. Download zlib-1.2.8.tar.gz from http://zlib.net/ and extract it into C:\BUILD
  4. Save the following batch file as C:\BUILD\build-curl64.bat
  5. Run build-curl64 from Windows command prompt
@echo off

:: 1) Path to MinGW-w64\bin
:: 2) Path to Microsoft LIB.exe
:: 3) Path to pexports.exe (http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/)
SET PATH=C:\Dev\MinGW64\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64;C:\Dev\MinGW\bin
SET ZLIB_PATH=C:\BUILD\zlib-1.2.8
SET INSTALL_DIR=C:\D\dmd2\windows
:: ---------------------------------------------------------------

:: Delete object files from previous build
del /S zlib-1.2.8\*.o curl-7.36.0\*.o curl-7.36.0\*.res

cd zlib-1.2.8
mingw32-make -fwin32/Makefile.gcc
cd ..

cd curl-7.36.0
mingw32-make -C lib -f Makefile.m32 CFG=mingw32-winssl-zlib LDFLAGS=-static
strip -s lib\libcurl.dll

mkdir %INSTALL_DIR%\bin64 %INSTALL_DIR%\lib64
copy lib\libcurl.dll %INSTALL_DIR%\bin64
pexports lib\libcurl.dll > curl.def
lib /MACHINE:X64 /DEF:curl.def /OUT:%INSTALL_DIR%\lib64\curl.lib
cd ..

:: Build sample
SET PATH=%INSTALL_DIR%\bin64;%INSTALL_DIR%\bin
dmd -m64 app.d -ofapp64.exe
app64