Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.45 KB

File metadata and controls

45 lines (29 loc) · 1.45 KB

Languages: English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Français | Deutsch | Español | Italiano | Русский | العربية

← NeverC Examples

Linux Math + zlib Example

Demonstrates math library functions and zlib compression cross-compiled to Linux using NeverC. Uses both -lm and -lz from the bundled sysroot.

NeverC bundles a Linux sysroot (Ubuntu 22.04, glibc 2.35) in runtime/linux/, so a single invocation handles preprocessing, compilation, optimization (auto-LTO), and linking via the built-in linker.

Build

From the repo (default target: x86_64-linux-gnu):

cd examples/linux-math
neverc make

Build for AArch64:

neverc make TARGET=aarch64-linux-gnu

Manual build (without Make)

neverc --target=x86_64-linux-gnu -Wall -lm -lz -o math-demo main.c

Run

Copy math-demo to a Linux machine (or Docker container) and execute:

chmod +x math-demo
./math-demo

What it does

  • Trigonometry: sin/cos/tan for 0° through 360°
  • Special functions: exp, log, tgamma (factorial), erf, cbrt, hypot
  • zlib compression: Compresses a string with compress2 (best compression), decompresses with uncompress, verifies roundtrip, computes CRC32