Building HAProxy with Cygwin
Tools Used
HAProxy - The Reliable, High-Performance TCP/HTTP Load Balancer
Cygwin - A Large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.
Resource Hacker - A Freeware resource compiler & decompiler for Windows® applications
GoRC (Go Resouce Compiler) - The Go tools for Windows + Assembler
Cygwin Installation
When installing Cygwin, make sure that at least the following modules are selected:
- gcc-core
- gcc-g++
- gcc-objc++
- glib2.0-openssl
- glib2.0-openssl-debuginfo
- libcrypt-devel
- libxmlsec1-openssl1
- libxmlsec1-openssl-devel
- make
- mingw64-x86_64-gcc-g++
- mingw64-x86_64-openssl
- openssl-debuginfo
- wget
Before building HAProxy, make sure Cygwin is fully updated.
Building HAProxy
Step 1
In Cygwin, download and unpack HAProxy with the following commands (version numbers only as an example):
- wget https://www.haproxy.org/download/2.6/src/haproxy-2.6.6.tar.gz
- tar zxf haproxy-2.6.6.tar.gz
For the latest version and download URL, please consult the HAProxy website.
Step 2
In a Cygwin prompt, run the following commands to build the HAProxy executable (version numbers only as an example):
- cd haproxy-2.6.6
- make clean
- make TARGET=cygwin CPU=native USE_LIBCRYPT=1 USE_OPENSSL=1 USE_LIBPCRE=1
- exit
Inside the HAProxy folder, you'll find the file called haproxy.exe
Although this already a usable file, I usually complete it with a decent icon and file info.
Step 3 (Optional)
First, we create a resource file that will be used with Resource Hacker to add version information to the file. In order to do that, create a tekstfile called haproxy.rc
Below an example of the contents of that file:
1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 2,6,6,0
FILEOS 0x0
FILETYPE 0x0
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileDescription", "HAProxy - The Reliable, High Performance TCP/HTTP Load Balancer."
VALUE "FileVersion", "2.6.6"
VALUE "ProductName", "HAProxy"
VALUE "ProductVersion", "2.6.6"
VALUE "LegalCopyright", "\xA9 2022 haproxy.org - Built with Cygwin by w8ff.be"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409 0x04E4
}
}
Adapt the information as you please to suit the correct version and information. Please keep the reference to haproxy.org in there as they earn the real credits for their fantastic work!
In a command prompt window, go to the folder where your haproxy.rc file is located and run the following command:
GoRC.exe /r haproxy.rc
This will create the actual resource file (haproxy.res) that can be used with Resource Hacker.
Run Resource Hacker and open the newly built haproxy.exe.
- Click "Action" => "Add from a Resource file".
- Open the haproxy.res file you created earlier.
- Select All
- Click "Action" => "Add using Script Template".
- Select "ICON" and click "Add".
- Set filename to HAProxy icon file (full path).
- Click the green arrow icon (Compile script).
- Click Save
You should now have a working haproxy.exe showing an HAProxy icon and the correct file version information when you check the file properties.
Finally ...
To use the haproxy.exe, you need some of the Cygwin DLL's either in the same folder or at least in a folder where the OS knows where to find them.
In total, you'll need the following files:
- cygcrypt-2.dll
- cygcrypto-3.dll
- cygssl-3.dll
- cygwin1.dll
- cygz.dll
- haproxy.exe
(Last updated December 08, 2023)