cURL / Mailing Lists / curl-library / Single Mail


Re: [Bulk] Re: [Bulk] Re: Trying to cross compile libcurl with MinGW 32-bit from Ubuntu, for Win32 Executables

From: Gisle Vanem <>
Date: Tue, 18 Feb 2014 11:45:01 +0100

<> wrote:

> LIBS = -lssl -lcrypto -lgdi32 -lssl -lcrypto -lwldap32 -lz -lws2_32

Why is '-lcrypto' given twice? That could be your problem.

> ../lib/curl-nonblock.o -L/path/to/mingw32/lib ../lib/.libs/libcurl.a
> -lgdi32 -lssl -lcrypto -lwldap32 -lz -lws2_32
> /path/to/mingw32/lib/libcrypto.a(rand_win.o):rand_win.c:(.text+0x1070):
> undefined reference to `_imp__CreateDCW_at_16'

Same problem since you didn't really change the Makefile (from ld's view);
'-lgdi32' is still before '-lcrypto'.

> ../lib/curl-nonblock.o ../lib/ -lssl -lcrypto -lgdi32 -lwldap32
> -lz -lws2_32
> $ cd ..
> finishes without error, then I just make again
> $ PATH=$PATH:/path/to/mingw32/bin make
> $ sudo make PATH=$PATH:/path/to/mingw32/bin install
> But when I test the static-only buildt curl.exe
> $ wine src/curl.exe
> err:module:import_dll Library zlib1.dll (which is needed by
> L"Z:\\path\\to\\mingw32\\libcurl\\curl-7.35.0\\src\\curl.exe") not found
> err:module:LdrInitializeThunk Main exe initialization for

The wine-loader is looking for zlib1.dll since 'ld' has picked up the import-lib
and not the static lib.

> L"Z:\\path\\to\\mingw32\\libcurl\\curl-7.35.0\\src\\curl.exe" failed,
> status c0000135
> which I dont have, I only have the static zip libraries: libz.a libz.dll.a

Correction, 'libz.a' is the *static-lib*. And 'libz.dll.a' is the import-lib for

GNU 'ld' uses some IMHO rather silly heuristics to set it's libs. From the ld
manual (applies to MingW on Windows. Probably applies to cross-building too):

  [...] when ld is called with the argument `-lxxx' it will attempt to
  find, in the first directory of its search path,

    cygxxx.dll (*)

Since you seems to want an all-static curl.exe, you should force
'ld' to use an explicit static lib:

Not sure how you can make autotools do that. But then again, I don't trust
or use autotools. For the '-gdi32' problem, try this:

--- Git-latest/ 2014-02-04 13:58:25 +0000
+++ 2014-02-18 10:52:07 +0000
@@ -1483,7 +1483,7 @@
     *-*-msys* | *-*-mingw*)
       AC_MSG_CHECKING([for gdi32])
- LIBS="-lgdi32 $LIBS"
+ LIBS="$LIBS -lgdi32"
       AC_TRY_LINK([#include <windef.h>
                    #include <wingdi.h>],

List admin:
Received on 2014-02-18