Compiling Barnyard2 on Windows using the Cygwin UNIX emulator
Windows 10 / 11 / 2016 SE / 2019 SE / 2022 SE / 2025 SE
Introduction
This tutorial provides a straightforward, step-by-step framework for compiling Barnyard2 on Windows using the Cygwin UNIX emulator to achieve MySQL/PostgreSQL database support.
Copyright Notice
This document is Copyright © 2003-2026 Michael Steele. All rights reserved. Permission to distribute this document is hereby granted providing that distribution is electronic, in its original form, no money is involved, and this copyright notice is maintained. Other requests for distribution will be considered.
Use the information in this document at your own risk. Michael Steele disavows any potential liability of this document. Use of the concepts, examples, and/or other content of this document are entirely at your own risk.
This guide is written in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
All copyrights are owned by their respective owners, unless specifically noted otherwise. Third-party trademarks or brand names are the property of their owners. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark. Naming of particular products or brands should not be seen as endorsements.
Support Questions and Help
All support questions related to this specific tutorial MUST be directed to the specific forum where this Windows Intrusion Detection System (WinIDS) tutorial resides!
By request, a premium fee service is available for one-on-one dedicated support.
If you have not acquired this tutorial directly from the winsnort.com website, you most likely do not have the latest revision!
How to use this guide
Critical Requirement: When asked to "Open a CMD window with Administrator privileges", it must be completed exactly as written or the installation will fail.
Similarly, when asked to "Close a CMD window", you must do so or the sequence will fail.
Note: The user deploying this installation MUST be an active member of the local Administrators group.
Note: If the User Account Control (UAC) dialog box appears at ANY time during this installation, ALWAYS click "Yes" to continue, or the installation will fail.
Instructions on starting a command prompt as an Administrator:
In the Windows Search box, type cmd, and then press CTRL+SHIFT+ENTER.
Operating System and Configuration Setup
Using any 64-bit version of Windows with the latest service pack installed will suffice to compile Barnyard2.
This tutorial offers two methods for compiling Barnyard2 on Windows using the Cygwin UNIX emulator. It supports automated or manual compilations for either PostgreSQL or MySQL databases.
1) Automated Script Process
There is an included scripted process that, if set up properly, will automatically compile Barnyard2 into an executable. This automated routine compiles Barnyard2 and leaves the assimilated, compressed "Barnyard2" archive cleanly in the root of drive D:\.
2) Manual Step-by-Step Compile
The manual installation pathway gives you foundational exposure to how UNIX environments operate via Cygwin (a Unix-like environment and command-line interface for Microsoft Windows).
This tutorial runs on ANY modern 64-bit Microsoft Windows operating system and comes packaged with all necessary assets. Both the tutorial architecture and the automated script rely on hard-coded absolute directory paths.
Prepping for the Windows Intrusion Detection System (WinIDS) Tutorial
Downloading and extracting the 'WinIDS - Barnyard2 Software Development Pack'
Download The 'WinIDS - Barnyard2 Software Development Pack' to a temporary location.
Open File Explorer and navigate to your downloaded winids-b2sdp.zip file. Right-click the file and select Extract All.... In the target folder dialog box, type d:\by2temp. Uncheck the "Show extracted files when complete" checkbox and click extract. When prompted for a password, type w1nsn03t.c0m, click OK, and exit File Explorer.
Downloading additional, required support files for target databases
d:\by2temp working folder.
MySQL 8.0.46: Download and save the file to the d:\by2temp folder.
PostgreSQL 18.3: Download and save the file to the d:\by2temp folder.
Note: Intelligent detection handling handles versioning automatically:
- If it detects only the MySQL source code file, it will compile exclusively for MySQL.
- If it detects only the PostgreSQL source code file, it will compile exclusively for PostgreSQL.
- If it flags both engine source tarballs, it will gracefully compile support for both concurrently.
Warning: If multiple versions of the same database source code are found in the execution directory, the smart detection engine will safely abort.
How to compile Barnyard2 on Windows using the Cygwin UNIX emulator
The automated process for compiling Barnyard2
Selectable deployment tracks natively support:
- Compiling Barnyard2 for MySQL Database Support
- Compiling Barnyard2 for PostgreSQL Database Support
- Compiling Barnyard2 for Concurrent MySQL and PostgreSQL Database Support
Open a CMD window with Administrator privileges, type the following command, and press Enter:
cd /d d:\by2temp
At the command prompt, execute the automation playbook engine script and input your target selection options when requested:
powershell -NoProfile -ExecutionPolicy Bypass -NoExit -File "Compile-WinSnort.ps1"
The manual process for compiling Barnyard2
Installing Cygwin
Open File Explorer and enter the d:\by2temp directory. Double-click setup-x64.exe to run the native Cygwin utility installation pipeline, then safely close the explorer host window.
When the Cygwin Setup wizard welcomes you, select Next.
At the Choose Installation Type page, leave the default Install from Internet radio flag marked and select Next.
At the Choose Installation Directory step, navigate to the Select Root Install Directory input box, define it explicitly as d:\cygwin, and click Next.
At the Select Local Package Directory step, alter the package input field tracking string to read precisely d:\cygwin\downloads, and select Next.
When the notification alert prompts you stating "Directory d:\cygwin\downloads does not exist, would you like me to create it?", confirm by clicking Yes.
At the Select Connection Type configuration panel, click Next.
When the mirrors payload tracking site page Populates, choose http://cygwin.mirrors.hoobly.com out of the Choose A Download Site catalog, highlight it, and click Next.
Installing required Cygwin packages
When the Select Packages mapping interface displays, find the View selector option at the top and transition it from 'Minimal/Default' to Full.
Use the search dialogue field consecutively to locate each package name variant highlighted below. For each item, look under the 'Package' block, select the dropdown selector to the right, and mark the latest stable software build number for inclusion:
unzipzipbisonautomakecmakegcc-coregcc-g++libtoollibicu-devellibicu73- PostgreSQL Compiles Only:
flex(Select for flex, flex-debuginfo, and flexdll) makelibreadline-develzlibzlib-develperlpatchlibgmp-devellibedit-devel- MySQL Compiles Only:
libmariadb-devel - MySQL Compiles Only:
mariadb-common
Once all matching package versions are systematically configured, click Next at the bottom right corner.
Review the calculated change logs at the Review and confirm changes validation screen, and select Next.
When you reach the Installation Status and Create Icons interface summary panel, click Finish.
Installing the support programs
From your Windows Desktop screen, launch the newly created shortcut labeled Cygwin Terminal to open the virtual command prompt environment.
Execute the following commands sequentially, pressing Enter after each line code block block:
unzip /cygdrive/d/by2temp/barnyard2-master.zip -d /cygdrive/d/cygwin
mv /cygdrive/d/cygwin/barnyard2-master /cygdrive/d/cygwin/source
unzip /cygdrive/d/by2temp/WpdPack_4_1_2.zip -d /cygdrive/d/cygwin
cp -Rf /cygdrive/d/cygwin/WpdPack/Lib/* /cygdrive/d/cygwin/lib
cp -Rf /cygdrive/d/cygwin/WpdPack/Include/* /cygdrive/d/cygwin/usr/include
unzip /cygdrive/d/by2temp/includes.zip -d /cygdrive/d/cygwin/usr/include
perl -pi -e 's/`ref_system_id`/ref_system_id/g;' /cygdrive/d/cygwin/source/src/output-plugins/spo_database_cache.h
mv /cygdrive/d/cygwin/lib/libwpcap.a /cygdrive/d/cygwin/lib/libpcap.a
Prepping MySQL support for Barnyard2
Execute the following targeted source building operations steps cleanly inside the running Cygwin command console terminal:
tar -zxvf /cygdrive/d/by2temp/mysql-8.0.46.tar.gz -C /cygdrive/d/cygwin
perl -pi -e 's/AND NOT WIN32/AND WIN32/g' /cygdrive/d/cygwin/mysql-8.0.46/configure.cmake
sed -i '1s/^/SET(CMAKE_LEGACY_CYGWIN_WIN32=1)\n/' /cygdrive/d/cygwin/mysql-8.0.46/CMakeLists.txt
cd /cygdrive/d/cygwin/mysql-8.0.46
cmake . -DWITH_EDITLINE=system -DINSTALL_MYSQLTESTDIR=
make mysqlclient && make install
Prepping PostgreSQL support for Barnyard2
Execute the following targeted source building operations steps cleanly inside the running Cygwin command console terminal:
tar -zxvf /cygdrive/d/by2temp/postgresql-18.3.tar.gz -C /cygdrive/d/cygwin
cd /cygdrive/d/cygwin/postgresql-18.3
./configure
make && make install
Assimilating the Barnyard2 executable, and the support files
Run these structural file migration commands inside the open console prompt window to align build outputs into independent operational directory paths:
mkdir /cygdrive/d/barnyard2
mkdir /cygdrive/d/barnyard2/etc
mkdir /cygdrive/d/barnyard2/schemas
cp /cygdrive/d/cygwin/source/schemas/create* /cygdrive/d/barnyard2/schemas
cp /cygdrive/d/cygwin/usr/local/bin/barnyard2.exe /cygdrive/d/barnyard2
cp /cygdrive/d/cygwin/source/etc/barnyard2.conf /cygdrive/d/barnyard2/etc
cp /cygdrive/d/cygwin/bin/cygz.dll /cygdrive/d/barnyard2
cp /cygdrive/d/cygwin/bin/cygwin1.dll /cygdrive/d/barnyard2
cp /cygdrive/d/cygwin/bin/cygstdc++-6.dll /cygdrive/d/barnyard2
MySQL Build Tracks Only: Port over supporting dependency driver runtime files to target architecture folder blocks:
cp /cygdrive/d/cygwin/bin/cygmariadb-3.dll /cygdrive/d/barnyard2
cp /cygdrive/d/cygwin/bin/cygcrypto-1.1.dll /cygdrive/d/barnyard2
cp /cygdrive/d/cygwin/bin/cygiconv-2.dll /cygdrive/d/barnyard2
cp /cygdrive/d/cygwin/bin/cygssl-1.1.dll /cygdrive/d/barnyard2
PostgreSQL Build Tracks Only: Port over supporting dependency driver runtime files to target architecture folder blocks:
cp /cygdrive/d/cygwin/usr/local/pgsql/lib/cygpq.dll /cygdrive/d/barnyard2
Creating the final compressed Barnyard2 asset
Package the compiled installation outputs cleanly using zip tools via the following sequential steps inside the active Cygwin terminal:
cd /cygdrive/d/barnyard2
zip -r /cygdrive/d/barnyard2-2.1.14-b337.zip *
exit
D:\ drive storage volume.
Cleaning up the Barnyard2 compile environment residue
Open a native Windows command prompt window running with Administrator privileges and purge the remaining temporary development workspace using these tracking lines:
rmdir /S /Q d:\cygwin
RMDIR /S /Q "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Cygwin"
del %PUBLIC%\Desktop\Cygwin*
exit
In Conclusion
Congratulations, you have successfully completed compiling a standalone copy of Barnyard2 tailored specifically for native Windows operations using the Cygwin UNIX environment emulator with customized database linking extensions!
I hope this modular tutorial has served your framework objectives effectively. Please provide operational loop context, bug observations, or general strategy feedback. The architectural mission was to give you clear transparency into how these intricate software components communicate, helping you upgrade, modify, and manage your custom Windows Intrusion Detection System (WinIDS) configuration arrays with confidence.
Optional Companion Documents
- How to add Event Logging to a local Syslog Server Learn step-by-step methods to route baseline Snort alert logs down to localized logging server targets sitting inside active system topologies.
- How to add Event Logging to a remote Syslog Server Configure system rules to relay event packets outwards across dedicated networks to a remote logging collection engine.
- How to add Email Alerting to an existing Windows Intrusion Detection System (WinIDS) Set up automatic email notifications for critical, high-priority events triggered by your intrusion detection system.
- How to configure Barnyard2 to run as a service Configure Barnyard2 to run seamlessly in the background as a native Windows service.
- How to compile Barnyard2 on Windows using Cygwin A step-by-step reference layout covering modular definitions within building tracks.
- How to build and deploy a passive Ethernet tap A hardware-centric blueprint manual detailing low-level fabrication methods to construct raw, physical network tap mechanisms.
Updating Major Windows Intrusion Detection Systems (WinIDS) Components
- How to update the Snort Intrusion Detection Engine Keep your main detection core updated with the latest security releases and optimization patches.
- How to update the Windows Intrusion Detection Systems rules Maintain an updated signature database to defend your environment against modern threat signatures.
Debugging Installation Errors
Check the native Windows Event Viewer application. The majority of these infrastructure helper programs output actionable FATAL diagnostics sequences into the default Application log container when processing errors occur.
General Tutorial Issues
For general technical inquiries regarding this tutorial, click the support button at the top of this article or navigate to our community support forums.
Feedback
We welcome your feedback, update proposals, or recommendations. Please submit your thoughts directly to us HERE.
Michael E. Steele | Microsoft Certified Systems Engineer (MCSE)
Email Support: support@winsnort.com
Snort: Open Source Network IDS - www.snort.org
