Search code examples
curllibcurlmingw32cross-compiling

Minimal cURL cross compile for windows


I want to compile cURL from source to use in my Windows DLL project. For this, I installed a Virtual Machine with Ubuntu, downloaded cURL source from http://curl.haxx.se/download/curl-7.37.0.tar.bz2, unpacked and configured it like this:

    ./configure --prefix=$HOME/devel/curl3 --disable-ftp --disable-file\
 --disable-ldap --disable-dict --disable-telnet --disable-tftp\
 --disable-rtsp --disable-pop3 --disable-imap --disable-smtp\
 --disable-gopher --disable-ares --disable-debug --without-ssl\
 --without-zlib --without-libidn --build=i586-pc-linux-gnu\
 --host=i386-pc-mingw32 --disable-shared

So I have this output:

configure: Configured to build curl/libcurl:

  curl version:     7.37.0
  Host setup:       i386-pc-mingw32
  Install prefix:   /home/victor/devel/curl3
  Compiler:         gcc
  SSL support:      no      (--with-{ssl,gnutls,nss,polarssl,cyassl,axtls,winssl,darwinssl} )
  SSH support:      no      (--with-libssh2)
  zlib support:     no      (--with-zlib)
  GSS-API support:  no      (--with-gssapi)
  SPNEGO support:   no      (--with-spnego)
  TLS-SRP support:  no      (--enable-tls-srp)
  resolver:         default (--enable-ares / --enable-threaded-resolver)
  ipv6 support:     no      (--enable-ipv6)
  IDN support:      no      (--with-{libidn,winidn})
  Build libcurl:    Shared=no, Static=yes
  Built-in manual:  enabled
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     no
  LDAP support:     no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS support:    no      (--enable-ldaps)
  RTSP support:     no      (--enable-rtsp)
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  HTTP2 support:    disabled (--with-nghttp2)
  Protocols:        HTTP

Then I just do make & make install to create the files (libcurl.a and include/curl/)*. Everything just runs fine but the problem is: When I import the generated files, one header is missing: sys/socket.h. This header is not part of a clean MingW32 install and by this, the configure command with --host=i386-pc-mingw32 should not require it, as windows uses winsock, right?

What am I missing here?

Sorry for long question and thanks in advance.


Solution

  • I found out what was wrong;

    I had to download the mingw32 package and then set it as the toolchain for configure and make commands. The --host config was also wrong. The toolchain downloaded had to be pointed as "i586-pc-mingw32msvc" and the path was set as:

    PATH=(path/to/i586ming):$PATH ./configure <options described above>
    PATH=(path/to/i586ming):$PATH make
    PATH=(path/to/i586ming):$PATH make install
    

    And my output was correct.