A very basic HelloWorld with jextract and panama
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Apr 25 18:16:30 UTC 2023
Hi Rebecca,
I believe neither JNA nor JNR support C++, so I'm not 100% what you mean
here.
You would at the very least need to add "extern C" to your function
declaration, to make sure that no mangling occurs.
Before I answer further, please clarify what you would like to achieve -
if you really want to call a C++ library using Panama and jextract, I'm
afraid that's not possible at the moment (as is the case for the other
frameworks you mentioned).
If you are ok adding "extern C" or, if C++ is not really central to the
question you are asking, I'm happy to help further.
Please also refer to the tutorial here (assuming Java 20):
https://github.com/openjdk/panama-foreign/blob/78d460f04d93f3df8e8f703e78780a152793f44a/doc/panama_ffi.md
Maurizio
On 25/04/2023 19:08, Michel Trudeau wrote:
>
> [Moving to the right list]
>
> *From: *code-tools-dev <code-tools-dev-retn at openjdk.org> on behalf of
> Rebecca Ahlvarsson <rahlvarsson at gmail.com>
> *Date: *Tuesday, April 25, 2023 at 9:18 AM
> *To: *code-tools-dev at openjdk.org <code-tools-dev at openjdk.org>
> *Subject: *A very basic HelloWorld with jextract and panama
>
> This question is so basic that I must be missing something. Sorry if
> that's a dumb rookie question.
>
> I have the following C++ code:
>
> #include <iostream>
>
> using namespace std;
>
> void sayHello() {
> cout << "Hello, Panama!" << endl;
> }
>
> Great!!!
>
> Now how do I go about calling the "sayHello()" C++ method from Java
> using jextract and panama?
>
> *I can use Linux or Mac, you choose. And I have jextract built on both
> machines.*
>
> That's easy and straightforward with JNI, JNA and JNR. But not with
> Panama? :(
>
> Your help clarifying this issue will be greatly appreciated!
>
> -Rebecca
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230425/1325d80b/attachment-0001.htm>
More information about the panama-dev
mailing list