Native packages and downstream bindings¶
Use the installed C library from a program in C, C++, Fortran, Rust, R or
Julia. Each binding calls the same native implementation, libgpridge,
declared in gpr/capi/gpridge_c.h. The Fortran, Rust, R and Julia packages
live in directories of this repository (fortran/, rust/gpridge-sys,
r/gpridge, julia/GPRidge.jl) and are built from a checkout against an
installed library. None of them is on a package registry: CRAN, crates.io and
the Julia General registry return 404 for them (probed 2026-11-17).
Install GPRidge lists the routes that build the library; this page starts from
a finished installation.
The blocks below need an installed prefix, a Fortran compiler, R, Julia or a Rust toolchain that the documentation test host does not have, so each one is marked as not run. The “Checked” notes say what was run and where.
Build a library-only installation¶
The consumers need the library, its header, the pkg-config file and the CMake
package. They do not need the drivers, HDF5, Cap’n Proto or anneal. The library
links rgmin, so the build needs Rust 1.88 or newer and libclang
(LIBCLANG_PATH). The c-cpp job of .github/workflows/native-registries.yml
configures a build that way and installs it into a staging root with
tests/cinstall/smoke.sh:
meson setup builddir --prefix="$HOME/.local" --buildtype=release \
-Dwith_tests=false -Dwith_drivers=disabled -Dwith_python=false \
-Duse_hdf5=false -Duse_capnp=false -Duse_chemfiles=false \
-Duse_highs=false -Duse_ceres=false -Duse_openblas=false \
-Duse_openmp=false -Duse_mpi=false \
-Duse_readcon_db=disabled -Duse_anneal=disabled \
-Duse_highway=disabled -Duse_featomic=disabled -Duse_stdpar=disabled
meson compile -C builddir
meson install -C builddir
The CI job also passes -Dsimd_baseline= (empty) so that the library keeps the
compiler’s default instruction set; the block above leaves it out, which keeps
the x86-64-v3 default described in Build options. The build still needs Rust
(minimage, linkcell and rgmin call cargo) and libclang for rgmin’s bindgen, plus a C++20 compiler, Meson 1.8 or newer and
LAPACK. The full list is in Install GPRidge, and
a build with the drivers installs the same files plus gprn and gprd.
Checked: the option set above configures in the python pixi environment
(meson setup only; the build was not run for this page). The CI job builds
and installs it on ubuntu-latest.
Select an installation¶
An installation provides include/gpr/capi/gpridge_c.h, libgpridge,
gpridge.pc and the CMake package gpridgeConfig.cmake. Use the header
and the library from one installation. The pkg-config file and the CMake
package sit under the library directory, which is lib, lib64 or
lib/<triplet> (lib/x86_64-linux-gnu on Debian and Ubuntu). The pkg-config
file locates its prefix relative to itself (${pcfiledir}), so a moved prefix
still works when PKG_CONFIG_PATH names the directory that holds
gpridge.pc.
gpr_prefix=/path/to/installation
pc=$(find "$gpr_prefix" -name gpridge.pc -print -quit)
export PKG_CONFIG_PATH="$(dirname "$pc")${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
pkg-config --modversion gpridge
pkg-config --variable=c_abi_major gpridge
pkg-config --variable=c_abi_minor gpridge
The three commands print the software version, the C ABI major and the C ABI
minor, each on its own line. Compatibility is decided by GPR_ABI_CHECK() in a
compiled C caller: it accepts a library with the same major and a minor at or
above the caller’s header. A library that the loader cannot find fails before
that check runs.
Checked: the commands were run against a meson install --destdir tree of a
default build on an Ubuntu host, and printed the software version, 1 and the
ABI minor of gpr/capi/gpridge_c.h.
Keep the dependencies installed with libgpridge. On an HPC system, load
its toolchain module before running a consumer; Run on an HPC cluster covers
runtime paths and compiler compatibility.
C and C++¶
packaging/conda/smoke.c is a complete C caller. It calls GPR_ABI_CHECK()
and prints the version. Compile it with the pkg-config flags and run it with the
library directory on the loader path:
libdir=$(pkg-config --variable=libdir gpridge)
cc packaging/conda/smoke.c $(pkg-config --cflags --libs gpridge) -lm -o smoke_capi
LD_LIBRARY_PATH="$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" ./smoke_capi
gpridge <version>
Checked: this ran against the tree described above with the host cc (clang
18). Without the LD_LIBRARY_PATH setting the program stops with
error while loading shared libraries: libgpridge.so: cannot open shared object file.
For CMake, packaging/native/cmake/ builds a consumer that resolves
find_package(gpridge REQUIRED CONFIG), links the imported target
gpridge::gpridge and calls GPR_ABI_CHECK(). The target carries the
include path and the link requirements, and the package sets
gpridge_VERSION, gpridge_C_ABI_MAJOR and gpridge_C_ABI_MINOR.
cmake -S packaging/native/cmake -B build/native-consumer \
-DCMAKE_PREFIX_PATH="$gpr_prefix"
cmake --build build/native-consumer
build/native-consumer/gpridge_abi_check
gpridge <version>, C ABI <major>.<minor>
Checked: with the python pixi environment’s CMake and compiler, and
-Dgpridge_DIR=<prefix>/lib/x86_64-linux-gnu/cmake/gpridge in place of
CMAKE_PREFIX_PATH, the build ran and printed the line above. The same
CMAKE_PREFIX_PATH command, with the system CMake and compiler, found the
package; its link step then failed (see the table below). The C header also
accepts C++ callers.
Fortran and fpm¶
The Fortran module is distributed as source, because .mod files depend on the
compiler. fpm.toml builds fortran/gpridge.f90 and links the installed C
library (link = ["gpridge", "stdc++"]). The gpridge-fortran package builds
the libgpridge-fortran archive. fpm needs the native library directory on
LIBRARY_PATH at build time and on LD_LIBRARY_PATH at run time. The block
uses a Linux installation; on another platform use that platform’s search
mechanism.
gpr_libdir=$(pkg-config --variable=libdir gpridge)
export LIBRARY_PATH="$gpr_libdir${LIBRARY_PATH:+:$LIBRARY_PATH}"
export LD_LIBRARY_PATH="$gpr_libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fpm build
fpm test
fpm install --prefix "$PWD/build/fpm-prefix"
fpm test runs four programs: fortran_gpr, fortran_local_band,
fortran_neb_muller_brown and fortran_periodic_band (listed in fpm.toml).
Use the same Fortran compiler when you consume the installed module. See
Fortran for the callback interfaces, the array layout and the error handling.
Checked: by reading fpm.toml. fpm is not installed on the host that ran this
page. The fortran-fpm job of native-registries.yml runs fpm build,
fpm test and fpm install.
Rust¶
rust/gpridge-sys generates declarations from the C header with bindgen and
links the installed library. Its build.rs asks pkg-config for gpridge
0.6.0 or newer; when that fails it reads GPRIDGE_LIBDIR (the library
directory) and GPRIDGE_INCLUDE (the include directory or the header path).
bindgen needs libclang; set LIBCLANG_PATH when it is outside the system
search path. Rust binding gives the commands and the ownership rules.
R and Julia¶
r/gpridge and julia/GPRidge.jl call the C API. They do not implement the
searches and they do not rebuild the C++ library. They link the same installed
libgpridge that fpm links and that find_package(gpridge) imports.
libgpridge loads librgpot from the same directory, so that directory must
be on LD_LIBRARY_PATH for both.
gpr_libdir=$(pkg-config --define-prefix --variable=libdir gpridge)
export LD_LIBRARY_PATH="$gpr_libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
R CMD build --no-build-vignettes --no-manual "$GPRIDGE_ROOT/r/gpridge"
R CMD INSTALL --library="$R_LIBS_USER" gpridge_*.tar.gz
Rscript -e 'library(gpridge); stopifnot(abi_check()); cat("gpridge ABI check passed\n")'
# GPRIDGE_LIBRARY may name libgpridge directly. Otherwise Julia asks
# pkg-config.
julia --project="$GPRIDGE_ROOT/julia/GPRidge.jl" \
-e 'using GPRidge; abi_check(); println("GPRidge ABI check passed")'
GPRIDGE_ROOT is the source checkout and R_LIBS_USER the R library to
install into. julia --project=julia/GPRidge.jl -e 'using Pkg; Pkg.test()'
runs the Julia package tests.
The R package’s configure script runs pkg-config --exists gpridge, writes
src/Makevars from the pkg-config flags, and links librgpot from the library
directory with an rpath. Julia resolves the library from GPRIDGE_LIBRARY,
then from pkg-config (julia/GPRidge.jl/src/library.jl). A BinaryBuilder
recipe for a future GPRidge_jll is julia/GPRidge.jl/deps/build_tarballs.jl;
Yggdrasil has no GPRidge directory (probed 2026-11-17).
Checked: the two blocks above run in the installed-library step of
scripts/ci_docs_tests.sh where Rscript and julia are on the PATH. The
r-package and julia-package jobs of native-registries.yml run R CMD check --as-cran and Pkg.test() against an installed prefix.
Ownership and errors¶
C output buffers belong to the caller. Each opaque handle has a matching
destroy operation. Constructors return a null handle on failure;
status-returning operations return GPR_SUCCESS or a negative GPR_ERR_*. Read
gpr_last_error_message() and gpr_last_status() on the calling thread before
another C call changes that error state.
Use one thread at a time per handle. Distinct handles can be used concurrently. Set process-wide runtime configuration before starting searches. The ABI reference describes the plugin ABIs and the training-product providers, and Native library ABI checks describes the version stamps.
Troubleshooting¶
“Reproduced” means the message was produced on the host that ran this page.
Message or symptom |
Cause |
Fix |
Status |
|---|---|---|---|
|
The package is under |
Pass |
Reproduced with the |
|
The CMake package adds |
Install the C++ standard library development files for that compiler (on Debian and Ubuntu, the |
Reproduced with the system CMake and clang 18, which selected a GCC 14 directory that has no |
|
The loader does not search the library directory |
Put the library directory on |
Reproduced with the |
|
The R |
Export |
Read ( |
|
Julia cannot resolve the library |
Export |
Read ( |
|
|
Export |
Read ( |