“找不到cstdarg文件";在Rust项目的C绑定上运行jextract时 [英] "cstdarg file not found" when running jextract on the C binding for a Rust project

查看:85
本文介绍了“找不到cstdarg文件";在Rust项目的C绑定上运行jextract时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用Java的Project Panama使用Rust编写一个简单的整数加法函数.使用 cbindgen 条板箱生成了绑定后,运行jextract时出现以下错误:

I'm trying to get a simple integer addition function written in Rust working with Java's Project Panama. Having generated the bindings using cbindgen crate, I get the following error when running jextract:

jextract -t org.adder -L . -l adder-java --record-library-path -I /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdarg bindings.h -o adder-java.jar
java.lang.RuntimeException: /Users/ash/Code/adder/bindings.h:1:10: fatal error: 'cstdarg' file not found

我查看了示例给出了,但无法解读我出了什么问题.

I've looked at the examples given, but can't decipher what I'm getting wrong.

这是我的图书馆文件:

#[no_mangle]
pub extern "C" fn addition(a: u32, b: u32) -> u32 {
    a + b
}

以及生成的绑定(我想还需要 cstdint cstdlib new 的源):

And the generated bindings (will also need sources for cstdint, cstdlib and new I presume?):

#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>

extern "C" {

uint32_t addition(uint32_t a, uint32_t b);

} // extern "C"

我需要怎么做才能找到 jextract 来查找这些文件?

What do I need to do to get jextract to find these files?

推荐答案

正确的命令是 jextract -C -x -C c ++ -I/Library/Developer/CommandLineTools/usr/include/c ++/v1 -tadder -o adder.jar bindings.h .

-x c ++ 传递给clang,包括 -I 指定的路径.

Pass -x c++ to clang, include the path specified by -I.

这篇关于“找不到cstdarg文件";在Rust项目的C绑定上运行jextract时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆