# zlbustst **Repository Path**: lionelfung/zlbustst ## Basic Information - **Project Name**: zlbustst - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-26 - **Last Updated**: 2026-01-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # C Library Integration Guide This project demonstrates how to link pre-compiled C libraries with Rust using a `build.rs` script. ## Directory Structure ``` your-project/ ├── include/ # Place your C header files (.h) here ├── lib/ # Place your pre-compiled C library files here │ ├── libmylib.a # Linux/Mac static library │ ├── mylib.lib # Windows static library │ └── ... ├── src/ │ └── main.rs # Rust code that uses the C library ├── build.rs # Build script to link C libraries └── Cargo.toml # Project manifest ``` ## Setup Instructions 1. Place your C header files (`.h` files) in the `include/` directory 2. Place your pre-compiled C library files in the `lib/` directory: - On Linux/Mac: Static libraries typically have `.a` extension (e.g., `libmylib.a`) - On Windows: Static libraries typically have `.lib` extension (e.g., `mylib.lib`) 3. Update the `build.rs` file to use the correct library name in the `println!("cargo:rustc-link-lib=static=...")` line 4. Update the `src/main.rs` file to declare and use the C functions you want to call ## Using Your C Library In your `build.rs`, modify this line to match your library name: ```rust println!("cargo:rustc-link-lib=static=my_c_library"); // Replace 'my_c_library' with your actual library name ``` In your `src/main.rs`, declare your C functions like this: ```rust extern "C" { fn my_actual_c_function(param: i32) -> i32; } ``` Then call them from your Rust code: ```rust unsafe { let result = my_actual_c_function(42); println!("Result: {}", result); } ``` ## Building Run `cargo build` to compile your project with the linked C library.