This guide shows how to build OpenNEC on Windows using a standalone MinGW-w64 toolchain (64-bit).
- Install a MinGW-w64 toolchain
- Option A (recommended): download a standalone toolchain such as the Winlibs standalone builds (https://winlibs.com/) or the mingw-w64 installer builds. Choose an x86_64 target and the POSIX/SEH variant if offered.
- Option B: use a packaged installer for MinGW-w64 appropriate for your
environment. Ensure the installed toolchain provides
x86_64-w64-mingw32-gcc,x86_64-w64-mingw32-ar, andx86_64-w64-mingw32-ranlib(or equivalent prefixed binaries) and add the toolchainbin/directory to yourPATH.
- Prepare the build environment
- Ensure the MinGW-w64
bindirectory is on yourPATHso commands likex86_64-w64-mingw32-gccandx86_64-w64-mingw32-arare resolvable. - If you do not have a POSIX
make, use the shippedmingw32-makeor a GNUmakethat works with MinGW. Example usage below uses themakeinvocation the Makefile expects; if your system provides onlymingw32-make, use that name instead.
- Clone and prepare the repo
On Windows you can use PowerShell or the legacy Command Prompt. If you prefer
bash you can install Git for Windows (which provides Git Bash). Examples:
PowerShell:
git clone <repo-url>
Set-Location OpenNEC
# optionally: git checkout pc-compatibilitycmd.exe (Command Prompt):
git clone <repo-url>
cd OpenNEC
REM optionally: git checkout pc-compatibilityGit Bash (if installed via Git for Windows):
git clone <repo-url>
cd OpenNEC
# optionally: git checkout pc-compatibility- Build (use original matrix backend to avoid optional external libraries)
# Prefer the MinGW-w64 cross-toolchain binaries on PATH
make CC=x86_64-w64-mingw32-gcc BACKEND=original- The project includes a small
clock_gettimeshim; on MinGW-w64 this is usually provided by the CRT/pthreads implementation. The Makefile excludes the bundledsrc/compat_time.cwhen a MinGW toolchain is detected to avoid collisions. - For most builds you can use
BACKEND=originalto avoid requiring OpenBLAS or other numeric libraries. If you need high-performance BLAS on Windows, install a native Windows build of OpenBLAS and make surepkg-configand the library are available.
After building you can run a smoke test on Windows natively:
.\onec.exe test\example5.deckOr from a Unix-like shell in the toolchain environment:
./onec.exe test/example5.deck- Preferred: use
-hor--helpto show usage on any platform. - On Windows
cmd.exe,onec /?will also display help (traditional Windows form). - On Unix-like shells
?and*are shell globs — quote them if you intend to pass a literal?(e.g.onec '?').
- If you see missing symbols for threading or pthreads, ensure your MinGW distribution includes winpthreads. Some installers provide separate runtime packages for pthreads support.
- If
clock_gettimeconflicts occur, the Makefile will normally avoid compiling the project's shim for MinGW; ensure you are using the prefixed cross-toolchain (e.g.x86_64-w64-mingw32-gcc) so the Makefile detection works correctly.