Skip to content

Statically linking ngtcp2 and quictls/openssl on Windows #17101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jixinqi opened this issue Apr 19, 2025 · 2 comments
Closed

Statically linking ngtcp2 and quictls/openssl on Windows #17101

jixinqi opened this issue Apr 19, 2025 · 2 comments
Assignees
Labels
cmake TLS Windows Windows-specific

Comments

@jixinqi
Copy link

jixinqi commented Apr 19, 2025

I did this

To compile curl on Windows with MSVC and statically link all dependencies, I used these steps:

  1. Build quictls/openssl

Build Command:

git reset --hard
git clean -fdx
perl Configure VC-WIN64A Debug no-shared \
    --prefix=[path to ssl install] \
    --openssldir=[path to ssl install]/ssl
perl configdata.pm --dump
nmake
nmake test
nmake install
  1. Build ngtcp2

Build Command:

cmake -B build/ngtcp2
    -DCMAKE_INSTALL_PREFIX=[path to ngtcp2 install]
    -DCMAKE_BUILD_TYPE=DEBUG
    -DENABLE_OPENSSL=ON
    -DOPENSSL_ROOT_DIR=[path to ssl install]
    -DLIBNGHTTP3_INCLUDE_DIR=[path to libngtcp3 install]/include
    -DLIBNGHTTP3_LIBRARY=[path to libngtcp3 install]/lib
    -DENABLE_STATIC_LIB=ON
    -DENABLE_SHARED_LIB=OFF
    -DBUILD_TESTING=OFF
cmake --build   [path to ngtcp2 install] --config=DEBUG
cmake --install [path to ngtcp2 install] --config=DEBUG
  1. Build curl

Build Command:

cmake -B [path to curl install]
    -DCMAKE_INSTALL_PREFIX=    [path to curl install] \
    -DCMAKE_BUILD_TYPE=        Debug \
    -DBUILD_SHARED_LIBS=       OFF \
    -DBUILD_STATIC_LIBS=       ON \
    -DBUILD_TESTING=           OFF \

    -DCURL_CA_BUNDLE=          "./cacert.pem_path" \
    -DCURL_USE_OPENSSL=        ON \
    -DOPENSSL_ROOT_DIR=        [path to ssl install] \

    -DCURL_USE_LIBPSL=         ON \
    -DLIBPSL_INCLUDE_DIR=      [path to libpsl install]/include \
    -DLIBPSL_LIBRARY=          [path to libpsl install]/lib/psl.lib \
    -DLIBPSL_CFLAGS=           -DPSL_API= \

    -DNGHTTP3_INCLUDE_DIR=     [path to nghttp3 install]/include \
    -DNGHTTP3_LIBRARY=         [path to nghttp3 install]/lib/nghttp3.lib \
    -DNGHTTP3_CFLAGS=          -DNGHTTP3_STATICLIB= \

    -DUSE_NGTCP2=              ON \
    -DNGTCP2_INCLUDE_DIR=      [path to ngtcp2 install]/include \
    -DNGTCP2_LIBRARY=          [path to ngtcp2 install]/lib/ngtcp2.lib \
    -DNGTCP2_CFLAGS=           -DNGTCP2_STATICLIB=

Issue Explanation

The curl_openssl_check_quic function in CMakeLists.txt fails during compilation because crypt32.lib is not linked. This occurs when:

ngtcp2 and curl are both statically linked to quictls/openssl.
Static linking does not automatically resolve Windows-specific dependencies like crypt32, which provides cryptographic APIs (e.g. SSL_set_quic_use_legacy_codepoint)

I fixed this probrem:

Commit: jixinqi@f9252a6

I expected the following

No response

curl/libcurl version

PS Z:\curl-builder> Z:\curl-builder__install\curl\Debug\bin\curl.exe -V
curl 8.13.1-DEV (Windows) libcurl/8.13.1-DEV quictls/3.1.7 zlib/1.3.1.1-motley libpsl/0.21.5 nghttp2/1.65.90 ngtcp2/1.11.90 nghttp3/1.8.90
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS HSTS HTTP2 HTTP3 HTTPS-proxy IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets

operating system

windows 11

@bagder bagder added cmake Windows Windows-specific labels Apr 19, 2025
@bagder bagder changed the title Requesting PR to Fix Issues When Statically Linking ngtcp2 and quictls/openssl Statically linking ngtcp2 and quictls/openssl on Windows Apr 19, 2025
@vszakats
Copy link
Member

vszakats commented Apr 19, 2025

@jixinqi Does this patch fixes the issue for you?: #17102

@vszakats vszakats self-assigned this Apr 19, 2025
@vszakats vszakats added the TLS label Apr 19, 2025
@jixinqi
Copy link
Author

jixinqi commented Apr 20, 2025

@vszakats Yes, it works very well.

nbaws pushed a commit to nbaws/curl that referenced this issue Apr 26, 2025
Also fix to link the winsock library for WinCE there.

Reported-by: Jixinqi
Fixes curl#17101
Closes curl#17102
nbaws pushed a commit to nbaws/curl that referenced this issue Apr 26, 2025
Also fix to link the winsock library for WinCE there.

Reported-by: Jixinqi
Fixes curl#17101
Closes curl#17102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake TLS Windows Windows-specific
Development

Successfully merging a pull request may close this issue.

3 participants