liveBook · Manning

Dynamic linking

As explained in Refactoring to Rust

Dynamic linking is the process of resolving and loading library code separately from an executable, typically at program startup or runtime.

Dynamic linking packages library functionality separately from an executable, allowing a C program to use code compiled from Rust. The integration requires a C-compatible dynamic library, linker search path, exported calling convention, and recompilation. section 3.2.2

Rust-backed calculator

A C calculator declares solve, links against the Rust dynamic library, and invokes it at runtime. Early output demonstrates the connection; later output prints the received expression while preserving the C-facing interface.

How Refactoring to Rust covers it

How deep it goes
Explains Cargo configuration, linker paths, C ABI exports, pointer checks, and string conversion through a working integration.
Examples
Uses a C calculator, Rust solve function, Cargo configuration, gcc commands, linker errors, and runtime output.
What it assumes
Assumes familiarity with using libraries and a C program; teaches the Rust-to-C integration steps incrementally.
What you can do after
Operate/configure a Rust dynamic library and link it into a C calculator while validating pointers and C strings.
How it connects
Connects dynamic linking with C FFI, unsafe Rust, Cargo, C ABIs, linkers, and dynamic libraries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Refactoring to Rust. The section links point to the parts of the book it draws on.