Jump to content

Compiling Barnyard2 on Windows using the Cygwin UNIX emulator

ids.gif

Windows 10 / 11 / 2016 SE / 2019 SE / 2022 SE / 2025 SE

Last Date Revised: May 12, 2026

Written by: Michael E. Steele

Introduction

Barnyard2 will not compile on a 32-bit operating system using this tutorial!

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.

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'

It is imperative to only use the files included in the "WinIDS - Barnyard2 Software Development Pack" highlighted below. These files have been thoroughly tested and verified as cross-compatible with all supported Windows Intrusion Detection Systems (WinIDS) tutorials.

Download 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

It is imperative to only use the exact files downloaded from the direct URL links below. These packages have been validated explicitly for this WinIDS track. Pick your target database application framework below and save the asset directly into your newly created d:\by2temp working folder.

Download MySQL 8.0.46: Download and save the file to the d:\by2temp folder.

Download 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"
Note: Depending on allocated bare-metal compute resources (RAM/CPU cores) and chosen build parameters, execution cycles can last between 10 to 60 minutes. You may close this reference manual now and interface directly with the script stdout feedback loops.

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.

The fundamental core packages will begin initializing into your local environment directory.

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:

  • unzip
  • zip
  • bison
  • automake
  • cmake
  • gcc-core
  • gcc-g++
  • libtool
  • libicu-devel
  • libicu73
  • PostgreSQL Compiles Only: flex (Select for flex, flex-debuginfo, and flexdll)
  • make
  • libreadline-devel
  • zlib
  • zlib-devel
  • perl
  • patch
  • libgmp-devel
  • libedit-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.

The progress dashboard window will display downloading and staging telemetry for the base components alongside structural dependencies. This operations cycle can take several minutes to run through.

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

Bypass notice: Skip this section completely if PostgreSQL was chosen as your primary database framework infrastructure stack target! All core compilation processes must map directly to the active operational engine environment running live on your WinIDS server.

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

Bypass notice: Skip this section completely if MySQL was chosen as your primary database framework infrastructure stack target! All core compilation processes must map directly to the active operational engine environment running live on your WinIDS server.

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
The fully compiled, assimilated, and compressed Barnyard2 archive is now safely located in the root of your 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

Explore our companion add-on documentation library to expand your active Windows Intrusion Detection System (WinIDS) ecosystem footprint:

Updating Major Windows Intrusion Detection Systems (WinIDS) Components

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


×
×
  • Create New...