This example demonstrates generating Haskell bindings for MiniSat, a minimalistic open-source SAT solver.
Install the MiniSat library on your system. For example, on NixOS:
nix-shell -p minisat./generate-and-run.shThis script will:
- Build the minisat-c-bindings C library
- Create symbolic links for the shared library (see quirks below)
- Generate Haskell bindings using
hs-bindgen - Create
cabal.project.localwith the necessary configuration - Build and run the example program
The build process creates libminisat-c.so.1.0.0, but the linker needs the
standard naming convention symlinks:
ln -sf libminisat-c.so.1.0.0 libminisat-c.so
ln -sf libminisat-c.so.1.0.0 libminisat-c.so.1The generate-and-run.sh script handles this automatically. These symlinks
follow Linux shared library naming conventions:
libminisat-c.so→ linker name (used at compile time)libminisat-c.so.1→ soname (used at runtime)libminisat-c.so.1.0.0→ real name (actual library file)
See this explanation for more details.
The .cabal file includes extra-libraries: minisat-c, which tells the
linker to link against libminisat-c.so. The library name should match the
base name of the binary file (without the lib prefix and .so extension).