Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to use libecl in Java using JavaCPP #730

Open
matteodg opened this issue Sep 19, 2020 · 6 comments
Open

Add support to use libecl in Java using JavaCPP #730

matteodg opened this issue Sep 19, 2020 · 6 comments
Assignees

Comments

@matteodg
Copy link
Contributor

Hello,
I just wanted to let you know that I started to create all infrastructure to allow to use libecl in Java using JavaCPP.

The idea is to follow the instructions in JavaCPP Presets and add libecl as another library available among the presets.

Here is the PR I'm working on: bytedeco/javacpp-presets#947
I'm not a C/C++ expert, so I might need some help if someone is interested.

I would like to help to allow to use libecl in Java.

Thanks in advance!

@matteodg
Copy link
Contributor Author

I'm doing some progresses, but one problem I'm facing is that among the include file it seems there are circular dependencies: the includes need to be sorted, so they will declare and define types in a orderly fashion as all the library calls will end up in a single Java class. Is this a known problem?
Thanks for any hint!

@pinkwah
Copy link
Collaborator

pinkwah commented Oct 16, 2020

Hi! Sorry for the late response.

This seems like a pretty cool project. I'm not aware of anyone using Java at Equinor, however I think it's a nice idea worth pursuing.

The circular dependencies you mention is usually solved with include guards in C and C++. A well-written C program should let you select any include in any order.

If you have a list of includes with circular dependencies I'd be happy to take a look and see what I can do.

@matteodg
Copy link
Contributor Author

Hi here I am, thanks for the reply!

Basically JavaCPP is building a .dll to create a JNI (Java Native Interface) to libecl, so that all libecl functions are available to a Java application as well. By doing so there is a configuration file: in that file I listed all include files sorting them by using topological sorting. I did that by compiling a list of all dependencies from the #include statements in the libecl include files.

The topological sorting turned out not to be doable, but at least I got a partly sorted list. Then I tinkered with it by hand: the final result is the list in org/bytedeco/libecl/presets/libecl.java.
It seems now there is no problem with circular dependencies anymore.

Now I'm facing other errors when compiling: see the resulting JNI .cpp file jnilibecl.cpp.txt and the output from the compilation in using Maven maven-build-output.txt.

These are the lines with "error: ":

/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:5293:53: error: use of deleted function ‘ecl_type_struct::ecl_type_struct()’
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:72:8: error: uninitialized const member in ‘struct ecl_type_struct’
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:72:8: error: uninitialized const member in ‘struct ecl_type_struct’
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:5320:57: error: use of deleted function ‘ecl_type_struct::ecl_type_struct()’
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/util/type_macros.hpp:136:44: error: expected primary-expression before ‘int’
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:10451:12: error: scalar object ‘rval’ requires one element in initializer
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:55:1: error: expected unqualified-id before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:55:41: error: expected primary-expression before ‘,’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:56:1: error: expected primary-expression before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:56:41: error: expected primary-expression before ‘,’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:57:1: error: expected primary-expression before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:57:38: error: expected primary-expression before ‘,’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:58:1: error: expected primary-expression before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:58:39: error: expected primary-expression before ‘,’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:59:1: error: expected primary-expression before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:59:39: error: expected primary-expression before ‘,’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:60:1: error: expected primary-expression before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:79:17: error: cannot convert ‘ecl_data_type’ {aka ‘ecl_type_struct’} to ‘int’ in initialization
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:80:19: error: cannot convert ‘ecl_data_type’ {aka ‘ecl_type_struct’} to ‘int’ in initialization
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:81:20: error: cannot convert ‘ecl_data_type’ {aka ‘ecl_type_struct’} to ‘int’ in initialization
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:82:18: error: cannot convert ‘ecl_data_type’ {aka ‘ecl_type_struct’} to ‘int’ in initialization
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:84:18: error: cannot convert ‘ecl_data_type’ {aka ‘ecl_type_struct’} to ‘int’ in initialization
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:10487:12: error: scalar object ‘rval’ requires one element in initializer
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_util.hpp:96:69: error: expected unqualified-id before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_util.hpp:96:108: error: expected primary-expression before ‘,’ token
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_util.hpp:96:110: error: expected primary-expression before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:10493:12: error: scalar object ‘rval’ requires one element in initializer
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_file.hpp:41:3: error: expected unqualified-id before ‘{’ token
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:33009:47: error: invalid conversion from ‘jlong (*)(jlong)’ {aka ‘long long int (*)(long long int)’} to ‘long int (*)(long int)’ [-fpermissive]
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:34248:74: error: invalid conversion from ‘jint’ {aka ‘int’} to ‘int (*)(const void*)’ [-fpermissive]
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:49072:38: error: cannot convert ‘char*’ to ‘void (*)(void*)’
/home/matteo/code/javacpp-presets/current/libecl/target/native/org/bytedeco/libecl/linux-x86_64/jnilibecl.cpp:49091:51: error: cannot convert ‘char*’ to ‘void (*)(void*)’
/home/matteo/code/javacpp-presets/current/libecl/cppbuild/linux-x86_64/include/ert/ecl/ecl_type.hpp:83:18: error: cannot convert ‘ecl_data_type’ {aka ‘ecl_type_struct’} to ‘int’ in initialization

Any clue is welcome!

Here is the pull request to integrate libecl in the set of C/C++ libraries made available through JavaCPP: bytedeco/javacpp-presets#947

@pinkwah
Copy link
Collaborator

pinkwah commented Dec 17, 2020

Are there any updates on this, @matteodg ?

@pinkwah pinkwah self-assigned this Dec 17, 2020
@matteodg
Copy link
Contributor Author

Hi, sorry I hadn't had a chance yet, but I'll get to this again during these holidays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants