我想使用 Project Panama 的jextract工具来构建与 Rust 库的 Java 绑定。运行以下命令时,出现错误:
jextract -C -x -C c++ -I /Library/Developer/CommandLineTools/usr/include/c++/v1 -t adder -o adder.jar bindings.h
java.lang.RuntimeException: /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:93:15: fatal error: 'stdlib.h' file not found
我很困惑,因为包含路径包含stdlib.h:
ls /Library/Developer/CommandLineTools/usr/include/c++/v1/ | grep stdlib
cstdlib
stdlib.h
错误行仅包含#include_next <stdlib.h>.
我的 Rust 源代码是一个简单的函数:
#[no_mangle]
pub extern "C" fn addition(a: u32, b: u32) -> u32 {
a + b
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn adds() {
assert_eq!(addition(1, 2), 3);
}
}
标bindings.h头由cbindgencrate 生成:
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>
extern "C" {
uint32_t addition(uint32_t a, uint32_t b);
} // extern "C"
我需要做什么jextract才能找到stdlib.h?