How to build curl for Windows with a subfolder for addons?
I’m building curl in Debian for Windows using MinGW. My current build configuration is:
export T=x86_64-w64-mingw32
PKG_CONFIG_PATH="/root/winlibs/libpsl-mingw/lib/pkgconfig:\
/root/winlibs/libidn2-mingw/lib/pkgconfig:\
/root/winlibs/libunistring-mingw/lib/pkgconfig:\
/root/winlibs/libiconv-mingw/lib/pkgconfig:\
/root/winlibs/openssl-mingw/lib/pkgconfig:\
/root/winlibs/zlib-mingw/lib/pkgconfig:\
/root/winlibs/brotli-mingw/lib/pkgconfig:\
/root/winlibs/zstd-mingw/lib/pkgconfig:\
/root/winlibs/nghttp2-mingw/lib/pkgconfig:\
/root/winlibs/libssh2-mingw/lib/pkgconfig" \
CC=$T-gcc AR=$T-ar RANLIB=$T-ranlib STRIP=$T-strip \
../curl-8.16.0/configure --host=$T --build=$(uname -m)-pc-linux-gnu \
--prefix=/root/winlibs/curl-mingw-latest \
--with-zlib=/root/winlibs/zlib-mingw \
--with-ssl=/root/winlibs/openssl-mingw \
--with-ca-bundle="addons/cacert.pem" \
--with-nghttp2=/root/winlibs/nghttp2-mingw \
--with-brotli=/root/winlibs/brotli-mingw \
--with-zstd=/root/winlibs/zstd-mingw \
--with-libidn2=/root/winlibs/libidn2-mingw \
--with-libpsl=/root/winlibs/libpsl-mingw \
--with-libssh2=/root/winlibs/libssh2-mingw \
--enable-alt-svc \
--enable-headers-api \
--enable-hsts \
--enable-websockets \
--enable-ipv6 \
--enable-threaded-resolver \
--enable-shared
How do I configure the build so that all DLLs and executables from addons are placed in a separate ‘addons’ subfolder next to the main curl.exe, rather than all in one directory?
Building curl for Windows with a Separate Addons Folder
To build curl for Windows with a separate subfolder for addons, you need to properly configure the configure parameters and use additional installation commands. Here’s how to do it:
Table of Contents
- Analysis of Current Configuration
- Setting Up Build with Separate Addons Folder
- Modified Configure Command
- Post-Processing Files for Proper Structure
- Verification of Results
- Complete Build Example
Analysis of Current Configuration
Your current configuration already contains the important parameter --with-ca-bundle="addons/cacert.pem", which indicates the use of a structure with an addons folder. However, for complete separation of all DLL and executable files of addons, additional configuration will be required.
The problem is that by default, configure and make install place all binary files in one directory specified via --prefix.
Setting Up Build with Separate Addons Folder
To create the proper structure with a separate addons folder, you need to do the following:
- Use additional configure parameters that will help structure the output files
- Perform post-processing of files after building to move DLLs to the appropriate folders
- Correctly configure library paths for linking
Here are the key points for configuration:
Modified Configure Command
export T=x86_64-w64-mingw32
PKG_CONFIG_PATH="/root/winlibs/libpsl-mingw/lib/pkgconfig:\
/root/winlibs/libidn2-mingw/lib/pkgconfig:\
/root/winlibs/libunistring-mingw/lib/pkgconfig:\
/root/winlibs/libiconv-mingw/lib/pkgconfig:\
/root/winlibs/openssl-mingw/lib/pkgconfig:\
/root/winlibs/zlib-mingw/lib/pkgconfig:\
/root/winlibs/brotli-mingw/lib/pkgconfig:\
/root/winlibs/zstd-mingw/lib/pkgconfig:\
/root/winlibs/nghttp2-mingw/lib/pkgconfig:\
/root/winlibs/libssh2-mingw/lib/pkgconfig" \
CC=$T-gcc AR=$T-ar RANLIB=$T-ranlib STRIP=$T-strip \
../curl-8.16.0/configure --host=$T --build=$(uname -m)-pc-linux-gnu \
--prefix=/root/winlibs/curl-mingw-latest \
--exec-prefix=/root/winlibs/curl-mingw-latest \
--bindir=/root/winlibs/curl-mingw-latest/bin \
--libdir=/root/winlibs/curl-mingw-latest/lib \
--includedir=/root/winlibs/curl-mingw-latest/include \
--datarootdir=/root/winlibs/curl-mingw-latest/share \
--with-zlib=/root/winlibs/zlib-mingw \
--with-ssl=/root/winlibs/openssl-mingw \
--with-ca-bundle="share/cacert.pem" \
--with-nghttp2=/root/winlibs/nghttp2-mingw \
--with-brotli=/root/winlibs/brotli-mingw \
--with-zstd=/root/winlibs/zstd-mingw \
--with-libidn2=/root/winlibs/libidn2-mingw \
--with-libpsl=/root/winlibs/libpsl-mingw \
--with-libssh2=/root/winlibs/libssh2-mingw \
--enable-alt-svc \
--enable-headers-api \
--enable-hsts \
--enable-websockets \
--enable-ipv6 \
--enable-threaded-resolver \
--enable-shared \
--disable-static
Important changes:
- Added
--exec-prefix,--bindir,--libdir,--includedir,--datarootdirfor precise control over file placement - Changed the path for CA bundle to
share/cacert.pem - Added
--disable-staticto reduce size
Post-Processing Files for Proper Structure
After running make and make install, you need to create a structure with an addons folder:
# Create folder structure
mkdir -p /root/winlibs/curl-mingw-latest/bin
mkdir -p /root/winlibs/curl-mingw-latest/addons
# Move DLLs to addons folder
find /root/winlibs/curl-mingw-latest -name "*.dll" -not -path "*/bin/*" -exec mv {} /root/winlibs/curl-mingw-latest/addons/ \;
# Copy necessary DLLs from dependencies to addons
cp /root/winlibs/openssl-mingw/bin/*.dll /root/winlibs/curl-mingw-latest/addons/
cp /root/winlibs/zlib-mingw/bin/*.dll /root/winlibs/curl-mingw-latest/addons/
cp /root/winlibs/brotli-mingw/bin/*.dll /root/winlibs/curl-mingw-latest/addons/
cp /root/winlibs/zstd-mingw/bin/*.dll /root/winlibs/curl-mingw-latest/addons/
cp /root/winlibs/nghttp2-mingw/bin/*.dll /root/winlibs/curl-mingw-latest/addons/
cp /root/winlibs/libssh2-mingw/bin/*.dll /root/winlibs/curl-mingw-latest/addons/
# Leave only curl.exe and related files in bin
mv /root/winlibs/curl-mingw-latest/curl.exe /root/winlibs/curl-mingw-latest/bin/
mv /root/winlibs/curl-mingw-latest/curl-config /root/winlibs/curl-mingw-latest/bin/
# Remove empty folders
find /root/winlibs/curl-mingw-latest -type d -empty -delete
Verification of Results
After running these commands, you should get the following structure:
/root/winlibs/curl-mingw-latest/
├── bin/
│ ├── curl.exe
│ └── curl-config
├── addons/
│ ├── libcrypto-*.dll
│ ├── libssl-*.dll
│ ├── zlib1.dll
│ ├── brotlicommon.dll
│ ├── brotlidec.dll
│ ├── libzstd.dll
│ ├── libnghttp2.dll
│ └── libssh2.dll
├── lib/
│ ├── libcurl.dll
│ └── libcurl.dll.a
├── include/
│ └── curl/
└── share/
└── cacert.pem
Complete Build Example
Here’s a complete script for building with proper structure:
#!/bin/bash
export T=x86_64-w64-mingw32
export CURL_VERSION="8.16.0"
export PREFIX="/root/winlibs/curl-mingw-latest"
# Configure paths
PKG_CONFIG_PATH="/root/winlibs/libpsl-mingw/lib/pkgconfig:\
/root/winlibs/libidn2-mingw/lib/pkgconfig:\
/root/winlibs/libunistring-mingw/lib/pkgconfig:\
/root/winlibs/libiconv-mingw/lib/pkgconfig:\
/root/winlibs/openssl-mingw/lib/pkgconfig:\
/root/winlibs/zlib-mingw/lib/pkgconfig:\
/root/winlibs/brotli-mingw/lib/pkgconfig:\
/root/winlibs/zstd-mingw/lib/pkgconfig:\
/root/winlibs/nghttp2-mingw/lib/pkgconfig:\
/root/winlibs/libssh2-mingw/lib/pkgconfig"
# Clean previous build
rm -rf $PREFIX
# Configuration
PKG_CONFIG_PATH="$PKG_CONFIG_PATH" \
CC=$T-gcc AR=$T-ar RANLIB=$T-ranlib STRIP=$T-strip \
../curl-$CURL_VERSION/configure --host=$T --build=$(uname -m)-pc-linux-gnu \
--prefix=$PREFIX \
--exec-prefix=$PREFIX \
--bindir=$PREFIX/bin \
--libdir=$PREFIX/lib \
--includedir=$PREFIX/include \
--datarootdir=$PREFIX/share \
--with-zlib=/root/winlibs/zlib-mingw \
--with-ssl=/root/winlibs/openssl-mingw \
--with-ca-bundle="share/cacert.pem" \
--with-nghttp2=/root/winlibs/nghttp2-mingw \
--with-brotli=/root/winlibs/brotli-mingw \
--with-zstd=/root/winlibs/zstd-mingw \
--with-libidn2=/root/winlibs/libidn2-mingw \
--with-libpsl=/root/winlibs/libpsl-mingw \
--with-libssh2=/root/winlibs/libssh2-mingw \
--enable-alt-svc \
--enable-headers-api \
--enable-hsts \
--enable-websockets \
--enable-ipv6 \
--enable-threaded-resolver \
--enable-shared \
--disable-static
# Build and install
make -j$(nproc)
make install
# Create structure with addons folder
mkdir -p $PREFIX/bin
mkdir -p $PREFIX/addons
# Move DLLs
find $PREFIX -name "*.dll" -not -path "*/bin/*" -exec mv {} $PREFIX/addons/ \;
# Copy DLLs from dependencies
for dep in openssl zlib brotli zstd nghttp2 libssh2; do
if [ -d "/root/winlibs/${dep}-mingw/bin" ]; then
cp /root/winlibs/${dep}-mingw/bin/*.dll $PREFIX/addons/
fi
done
# Move main executables
mv $PREFIX/curl.exe $PREFIX/bin/
mv $PREFIX/curl-config $PREFIX/bin/
# Cleanup
find $PREFIX -type d -empty -delete
echo "Build completed. Structure:"
echo "$PREFIX/"
echo "├── bin/"
echo "├── addons/"
echo "├── lib/"
echo "├── include/"
echo "└── share/"
This script will create the proper structure with a separate addons folder for all DLLs and executable addon files, leaving the main curl.exe in the bin folder.
Sources
- Curl: Howto: Use libcurl with MinGW
- How to build/install libcurl on windows with MinGW
- Use libcurl in Dev-C++(MinGW)
- Windows - everything curl
- How to compile curlpp with Windows?
- Installing curl (for Windows)
Conclusion
- To create a separate addons folder, use parameters
--bindir,--libdir,--datarootdirfor precise control over file placement - After the main build, perform post-processing to move DLLs to the addons folder
- Copy necessary DLLs from dependencies (openssl, zlib, brotli, zstd, nghttp2, libssh2) to addons
- Keep the main curl.exe in the bin folder for convenience
- This structure makes application deployment cleaner and more organized
This configuration will allow you to have a clear separation between curl’s main files and dependencies, which is especially important when deploying applications on Windows.