Linking with C library

How I can remove leading underscore from symbol names in extern block?
For example, i have a C library (acpica), and try call AcpiInitializeSubsystem from rust code.
But in library this function does not have leading undescore, and while linking my code ld return error and say, that in rust code this function imported with leading underscore.

I haven’t completely understood your setup (Rust calling FFI, or FFI calling Rust), but here are three interesting Rust attributes:

  • Calling Rust code from FFI
    #[no_mangle] pub extern "C" on a Rust function, to be able to call it from FFI,

    • According to this 2016 comment, the #[export_name = "\x01AcpiInitializeSubsystem"] could prevent LLVM from adding a leading underscore;
  • Calling FFI code from Rust
    you can use the #[link_name = "_AcpiInitializeSubsystem"] on an extern "C" { fn AcpiInitializeSubsystem (...) -> ...; } declaration, so that the usable function does not have a leading underscore whilst still linking against an (external / FFI) function with such leading underscore.