Compiling Binaries
Linux Target
Basic C
Windows Target
Basic C Compilation 32-bit “Hello World” (console) 64-bit “Hello World” (console) Basic C++ Compilation 32-bit C++ (console) 64-bit C++ (console) Setting Windows Version Macros To target a minimum Windows version, define_WIN32_WINNT and WINVER:
# Example: target Windows 7 (0x0601)
x86_64-w64-mingw32-gcc -D_WIN32_WINNT=0x0601 -DWINVER=0x0601 hello.c -o hello.exe
_WIN32_WINNT values:
0x0501→ Windows XP0x0600→ Windows Vista0x0601→ Windows 70x0602→ Windows 80x0A00→ Windows 10
.NET Excutables
Compile to a portable .NET EXE (IL-only) using Mono’s C# compiler (mcs):
Basic 64-bit Windows EXE
For 32-bit Windows (Win32)
.csproj
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install -y dotnet-sdk-7.0
YourProject.csproj in that directory (or a parent directory).
Restore dependencies
Build
- By default, the output goes into
bin/Release/<TargetFramework>/ - If you want to target a specific runtime (e.g. Windows), use: Target runtime