Difference between revisions of "Curl on Windows"

From D Wiki
Jump to: navigation, search
(Update curl-7.36.0)
m
Line 97: Line 97:
 
app64
 
app64
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
----
 +
[[Category:curl]]
 +
[[Category:Winwows]]

Revision as of 11:31, 27 April 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