curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Curl as static library with dependencies

From: Jeroen Ooms via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 22 Nov 2019 13:34:12 +0100

The msys2 project provides up-to-date mingw-w64 builds for all these
libraries, shared and static. This is what everyone uses to build with
mingw-w64. Just download msys2 and run:

   pacman -S mingw-w64-{i686,x86_64}-curl

Alternatively you can download the msys2 builds manually from:
http://repo.msys2.org/mingw/

You can then get the correct build and linker flags using e.g.:

  pkg-config --cflags --static libcurl
  pkg-config --libs --static libcurl

The main gotcha is that you need to compile your application that
links against libcurl with -DCURL_STATICLIB to support static linking.

On Fri, Nov 22, 2019 at 11:38 AM amchess via curl-library
<curl-library_at_cool.haxx.se> wrote:
>
> Thanks for your answer.
>
>
> I want to compile in windows x64 with msys the following code:
>
> https://github.com/noobpwnftw/Stockfish/tree/livebook
> With the following dlls in the src folder and eliminating the LDFLAGS += -static in the Makefile, it works:
>
> libcurl-x64.dll
> libcrypto_1_1-x64.dll
> libssl_1_1-x64.dll
> libssl_1_1-x64.dll
> libssh2_x64.dll
> libbrotlicommon.dll
> libbrotlidec.dll
> libbrotlienc.dll
>
> but I need a static (LTO) build.
>
> So,
> - I got the static libraries and their includes.
> - I copied them into MinGW lib and include folders.
> - I launched the following command:
>
> mingw32-make profile-build ARCH=x86-64-bmi2 COMP=mingw CXX=x86_64-w64-mingw32-g++ -j14
>
> but I have errors like the following:
>
> C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib\libcurl.a(libcurl_la-connect.o):(.text+0x66): undefined reference to `__imp_getsockopt' C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib\libcurl.a(libcurl_la-connect.o):(.text+0x92): undefined reference to `__imp_WSAGetLastError' C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib\libcurl.a(libcurl_la-connect.o):(.text+0x2a0): undefined reference to `__imp_inet_ntop' ...
>
> I tried to specify the flag -lws2_32 at the end of the command and also the entire dependencies chain:
>
>
> mingw32-make profile-build ARCH=x86-64-bmi2 COMP=mingw CXX=x86_64-w64-mingw32-g++ -j14 -lz -lbrotlicommon-static -lbrotlidec-static -lssh2 -lnghttp2 -lssl -lcurl -lwsock32 -lwinsock2 -lws2_32 -lcrypto -lcrypt32 -lbcrypt -lwldap32
> but nothing changes.
> What am I missing?
> Many thanks in advance,
> Andrea
>
>
>
>
> Il 21 novembre 2019 alle 17.16 Daniel Stenberg <daniel_at_haxx.se> ha scritto: On Tue, 19 Nov 2019, amchess
>
> -------------------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-11-22