How do I build libcurl for 64-bit Windows in/using Visual Studio 2010?

NobleUplift picture NobleUplift · Feb 14, 2016 · Viewed 7.1k times · Source

So initially, I followed the instructions of BUILD.WINDOWS.txt and I was able to get libcurl building 32-bit by creating a new file winbuild.bat and placing it in the root directory of my curl folder:

CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
CD winbuild
DEL CURL_OBJS.inc
DEL LIBCURL_OBJS.inc
DEL vc100.idb
nmake /f Makefile.vc mode=dll VC=10 ENABLE_WINSSL=yes GEN_PDB=yes MACHINE=X86
CD ..
EXIT /B 0

I then went to File / New / Project from Existing Code... / Visual C++ / Use external build system / Build command line: winbuild.bat. I tried to create a new Platform in my properties for x64, with winbuild64.bat:

CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
CD winbuild
DEL CURL_OBJS.inc
DEL LIBCURL_OBJS.inc
DEL vc100.idb
nmake.exe /f Makefile.vc mode=dll VC=10 ENABLE_WINSSL=yes GEN_PDB=yes MACHINE=x64 DEBUG=no
CD ..
EXIT /B 0

But this is my output for winbuild64.bat:

Setting environment for using Microsoft Visual Studio 2010 x64 tools.

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

configuration name: libcurl-vc10-x64-release-dll-ipv6-sspi-winssl
Using SSL:
Using c-ares:
Using SSH2:
Using ZLIB:
Using IDN: true
Using IPv6: true
Using SSPI: true
Using WinSSL: true
CFLAGS: /I. /I ../lib /I../include /nologo /W3 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL /I"../../deps/include" /DUSE_WIN32_IDN /DWANT_IDN_PRO
TOTYPES /DUSE_IPV6 /DUSE_WINDOWS_SSPI /DUSE_SCHANNEL /Zi /Fd"..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib\libcurl.pdb"
LFLAGS: /nologo /machine:x64 "/LIBPATH:../../deps/lib" /incremental:no /opt:ref,icf
GenPDB: true
Debug: no
Machine: x64
        link.exe /DLL ws2_32.lib wldap32.lib advapi32.lib Normaliz.lib /out:..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib\libcurl.dll  /IMPLIB:..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib\libcurl.lib /nologo /machine:x64 "/LIBPATH:../../deps/lib" /incremental:no /opt:ref,icf ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/file.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/timeval.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/base64.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hostip.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/progress.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/formdata.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/cookie.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/http.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/sendf.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/ftp.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/url.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/dict.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/if2ip.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/speedcheck.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/ldap.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/version.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/getenv.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/escape.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/mprintf.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/telnet.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/netrc.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/getinfo.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/transfer.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/strequal.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/easy.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/security.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_fnmatch.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/fileinfo.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/ftplistparser.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/wildcard.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/krb5.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/memdebug.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/http_chunks.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/strtok.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/connect.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/llist.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hash.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/multi.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/content_encoding.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/share.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/http_digest.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/md4.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/md5.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/http_negotiate.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/inet_pton.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/strtoofft.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/strerror.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/amigaos.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hostasyn.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hostip4.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hostip6.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hostsyn.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/inet_ntop.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/parsedate.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/select.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/tftp.obj ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/splay.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/strdup.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/socks.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/ssh.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/rawstr.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_addrinfo.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/socks_gssapi.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/socks_sspi.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_sspi.obj..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/slist.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/nonblock.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_memrchr.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/imap.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/pop3.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/smtp.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/pingpong.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/rtsp.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_threads.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/warnless.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hmac.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_rtmp.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/openldap.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_gethostname.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/gopher.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/idn_win32.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/http_negotiate_sspi.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/http_proxy.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/non-ascii.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/asyn-ares.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/asyn-thread.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_gssapi.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_ntlm.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_ntlm_wb.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_ntlm_core.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_ntlm_msgs.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_sasl.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_multibyte.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/hostcheck.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/conncache.obj..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/pipeline.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/dotdot.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/x509asn1.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/http2.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_sasl_sspi.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/smb.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_sasl_gssapi.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_endian.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/curl_des.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/openssl.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/gtls.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/vtls.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/nss.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/polarssl.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/polarssl_threadlock.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/axtls.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/cyassl.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/schannel.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/darwinssl.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/gskit.obj  ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/vtls/mbedtls.obj   ..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib\libcurl.res
..\builds\libcurl-vc10-x64-release-dll-ipv6-sspi-winssl-obj-lib/file.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\link.exe"' : return code '0x458'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\nmake.exe"' : return code '0x2'
Stop.

I was able to build 32-bit in Command Prompt, and I tried both Visual Studio Command Prompt (2010) and Visual Studio x64 Win64 Command Prompt (2010), but neither worked.

I've read this answer and it seems like I can create a project and then run nmake from inside Visual Studio 2010, but I can't figure out how to have it work within the winbuild directory during compilation.

The code in my project is finished and all I have left to do is build the dependencies to get the dll and lib files for deployment. I've been debugging off of a libcurl 7.25.0 build this whole time lol and I'm trying to build 7.47.1. All help appreciated.

Answer

Umar Hassan picture Umar Hassan · Aug 28, 2016

Its simple.
1: install windows SDK, VS with VC,
2: download latest curl release
3: Win+R cmd
4: cd to to [your vs installation]\VC\bin[amd64 or x86_amd64], use the folder according to the type of build you want (i used amd64 on a 64bit machine to use curl dll on my 64 win 8.1
5: run vcvars64 or vcvars32 accordingly
6: cd to [extracted CURL dir]\winbuild
7: run:
nmake /f makefile.vc ENABLE_WINSSL=yes mode=dll MACHINE=x64 VC=13 use x64 and VC version according to your installation. e.g. VS 2013 is 13

It will take some time and build a dll in \CURL\builds\libcurl-vc13-x64-release-dll-ipv6-sspi-winssl or \CURL\builds\libcurl-vc13-x86-release-dll-ipv6-sspi-winssl


if cmd can't find nmake, in the system PATH variable, add this: blah blah;bleb, bleh bleh;[your VS installation dir]\VC\bin


confirm that the specified folder contains an nmake.exe.