【发布时间】:2020-07-07 13:20:39
【问题描述】:
我想使用 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 标头由 cbindgen crate 生成:
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>
extern "C" {
uint32_t addition(uint32_t a, uint32_t b);
} // extern "C"
jextract 需要做什么才能找到stdlib.h?
【问题讨论】:
-
这和Java有什么关系?
-
这不是通过与您之前的问题“cstdarg file not found” when running jextract on the C binding for a Rust project 相同的技术解决的吗?您是否要为项目中的每个唯一标头提出相同的问题?请edit您的问题故意链接到您之前的问题,并澄清这个问题的不同之处。
-
我不是。当我发布时,我认为这是一个不同的问题。进一步研究后,它大致相似。
-
@NomadMaker 这是 OpenJDK Project Panama。 jextract 工具由 JDK 提供。
-
不知道为什么这个问题被否决了,但是这个问题的解决方案帮助我解决了一个问题。继续问!
标签: java rust ffi project-panama