2 unstable releases

0.9.0 Jul 7, 2021
0.8.0 May 27, 2021

#364 in Science

Used in libceed


28K SLoC

C 18K SLoC // 0.3% comments C++ 9K SLoC // 0.1% comments Rust 78 SLoC // 0.3% comments

libceed-sys: unsafe bindings to libCEED

This is the documentation for the low level (unsafe) Rust bindings to the libCEED C interface. See the libCEED user manual for usage information. Note that most Rust users will prefer the higher level (safe) Rust interface in the libceed crate.

libCEED is a low-level API for for the efficient high-order discretization methods developed by the ECP co-design Center for Efficient Exascale Discretizations (CEED). While our focus is on high-order finite elements, the approach is mostly algebraic and thus applicable to other discretizations in factored form.


To use low level libCEED bindings in a Rust package, the following Cargo.toml can be used.

libceed-sys = "0.9.0"

For a development version of the libCEED Rust bindings, use the following Cargo.toml.

libceed-sys = { git = "https://github.com/CEED/libCEED", branch = "main" }

Supported features:

  • static (default): link to static libceed.a
  • system: use libceed from a system directory (otherwise, install from source)


To develop libCEED, use cargo build in the rust/libceed-sys directory to install a local copy and build the bindings.

If you need custom flags for the C project, we recommend using make -C c-src configure to cache arguments in c-src/config.mk. If that file exists during cargo build then edits will prompt recompilation of the bindings.

Shared libraries

If one is developing libCEED C source and testing multiple language bindings at once, a few seconds can be cut out of the edit/compile/test loop by disabling the static feature and using

export PKG_CONFIG_PATH=$CEED_DIR/lib/pkgconfig

Without system

If you disable the static feature and are not using a system version from a standard path/somewhere that can be found by pkg-config, then you'll need to set LD_LIBRARY_PATH to the appropriate target directory for doctests to be able to find it. This might look like

export LD_LIBRARY_PATH=$CEED_DIR/target/debug/build/libceed-sys-d1ea22c6e1ad3f23/out/lib

where the precise hash value is printed during cargo build --verbose or you can find it with find target -name libceed.so. This mode of development is more fragile than the default (which uses static libraries).

Note that the LD_LIBRARY_PATH workarounds will become unnecessary if this issue is resolved -- it's currently closed, but the problem still exists.

License: BSD-2-Clause


The libceed-sys crate is developed within the libCEED repository. See the contributing guidelines for details.


~30K SLoC