我可能没有正确描述我的问题标题,如果需要请编辑它.
我正在尝试为LXC库创建一个Rust接口,这是用C语言编写的.
我已成功调用简单函数lxc_get_version,lxc_container_new但我无法访问struct lxc_container块中描述的函数.
这是我的代码的一部分:
#[link(name = "lxc")]
extern {
// LXC part
fn lxc_get_version() -> *const c_char;
fn lxc_container_new(name: *const c_char, configpath: *const c_char) -> LxcContainer;
// LXC container parts
fn is_defined(container: &LxcContainer) -> bool;
}
Run Code Online (Sandbox Code Playgroud)
这是一个错误:
note: test.o: In function `LxcContainer::is_defined::heb2f16a250ac7940Vba':
test.0.rs:(.text._ZN12LxcContainer10is_defined20heb2f16a250ac7940VbaE+0x3e): undefined reference to `is_defined'
Run Code Online (Sandbox Code Playgroud)
编辑:我已经管理了C结构中的函数称为函数指针.我试过谷歌像"Rust C函数指针",但没有运气.