2

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.

Here is my library file:

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

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"

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

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
junglie85
  • 1,243
  • 10
  • 30

1 Answers1

1

The correct command is jextract -C -x -C c++ -I /Library/Developer/CommandLineTools/usr/include/c++/v1 -t adder -o adder.jar bindings.h.

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

junglie85
  • 1,243
  • 10
  • 30