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

Build monero-java and monero-cpp to static libraries with shared library wrapper [4 XMR] #795

Open
woodser opened this issue Feb 25, 2024 · 25 comments
Labels
💰bounty There is a bounty on this issue

Comments

@woodser
Copy link
Contributor

woodser commented Feb 25, 2024

This issue requests building monero-java and monero-cpp to static libraries so all dependencies are self-contained, with a shared library wrapper to access libmonero-java in JNI.

For example: libmonero-cpp.a, libmonero-java.a, and libmonero-java.so.

This will help us switch from using monero-wallet-rpc to native wallet bindings for better performance, and without depending on MSYS2 in Windows.

This issue shares the same bounty as the related issue in monero-java: woodser/monero-java#74

@woodser woodser added the 💰bounty There is a bounty on this issue label Feb 25, 2024
Copy link

There is a bounty on this issue, the amount is in the title. The reward will be awarded to the first person or group of people who resolves this issue.

If you are starting to work on this bounty, please write a comment, so that we can assign the issue to you. We expect contributors to provide a PR in a reasonable time frame or, in case of an extensive work, updates on their progresses. We will unassign the issue if we feel the assignee is not responsive or has abandoned the task.

Read the full conditions and details of our bounty system.

@woodser woodser closed this as completed Mar 2, 2024
@woodser woodser changed the title Build monero-java and monero-cpp to static libraries with dynamic library wrappers [1 XMR] Build monero-java and monero-cpp to static libraries with shared library wrapper [2 XMR] Apr 2, 2024
@woodser woodser reopened this Apr 2, 2024
@niyid
Copy link
Contributor

niyid commented Apr 5, 2024 via email

@woodser
Copy link
Contributor Author

woodser commented Apr 5, 2024

I think the only issue is that the dynamic libraries require MSYS2 to be installed and on the Path variable in Windows, whereas static libraries would be self-contained and shouldn't require external dependencies.

@niyid
Copy link
Contributor

niyid commented Apr 5, 2024 via email

@woodser
Copy link
Contributor Author

woodser commented Apr 5, 2024

No, creating static libraries with a shared library wrapper is the request of this issue.

@niyid
Copy link
Contributor

niyid commented Apr 5, 2024

I think the only issue is that the dynamic libraries require MSYS2 to be installed and on the Path variable in Windows, whereas static libraries would be self-contained and shouldn't require external dependencies.

I am not clear what the issue is from here. I summize it is an issue with MSYS2 on Windows; and that this is a Windows only issue.

@woodser
Copy link
Contributor Author

woodser commented Apr 5, 2024

The libraries should not have external dependencies which need to be installed, but should be standalone, which switching to static libraries ought to support?

Otherwise, someone installing Haveno and using the native libraries would additionally need to install MSYS2.

@mcneb10
Copy link

mcneb10 commented Apr 26, 2024

I would like to look into this

@woodser
Copy link
Contributor Author

woodser commented Apr 27, 2024

@mcneb10 Great!

@woodser
Copy link
Contributor Author

woodser commented Jun 23, 2024

@mcneb10 Any progress?

Currently, the dynamic libraries built for Linux only work on Ubuntu 20.0.4 as far as I know (what they're built from). But there's a linker error on later versions.

This would be resolved by building to static libraries.

@woodser woodser changed the title Build monero-java and monero-cpp to static libraries with shared library wrapper [2 XMR] Build monero-java and monero-cpp to static libraries with shared library wrapper [3 XMR] Jun 23, 2024
@woodser
Copy link
Contributor Author

woodser commented Jun 23, 2024

Bounty bumped to 3 XMR.

@mcneb10
Copy link

mcneb10 commented Jun 23, 2024

I'm sorry I have been distracted and unmotivated recently. I was not able to compile to source due to some linking errors with the unbound package. I will have another look today.

@woodser
Copy link
Contributor Author

woodser commented Jun 23, 2024

No worries, we can leave this unassigned if it doesn't work out.

@woodser
Copy link
Contributor Author

woodser commented Jun 23, 2024

@mcneb10 Please ping me if I can help with the linker error. I've built it a few times :)

@preland
Copy link
Contributor

preland commented Jun 23, 2024

Is this issue related to the mac universal issue on Haveno?

@woodser
Copy link
Contributor Author

woodser commented Jun 23, 2024

Not quite. That issue is to create universal binaries which run natively on mac x86_64 and arm64 without emulation, whereas this issue is to build the monero-java libs to static libraries with a dynamic wrapper on all platforms, for portability. Othewise, the libs built on Ubuntu 20.04 can't run on 22.04.

@mcneb10
Copy link

mcneb10 commented Jun 23, 2024

Note to anyone compiling this: if you try to compile on anything except a distro based on stable debian you will run into errors very quickly

@nsec1
Copy link
Contributor

nsec1 commented Jun 26, 2024

@woodser , I need help to integrate new monero-java.so to haveno. Do I just have to "mvn install" on monero-java and then build haveno with make?

@woodser
Copy link
Contributor Author

woodser commented Jun 26, 2024

I believe you can simply add the path to the newly built libraries to your CLASSPATH variable and then start Haveno with --useNativeXmrWallet=true.

But to do a complete install:

  • Bump 0.8.31 to 0.8.32 in monero-java's pom.xml
  • In monero-java: mvn clean deploy -P release -Dmaven.deploy.skip=true
  • Bump moneroJavaVersion to 0.8.32 in Haveno's build.gradle
  • Uncomment mavenLocal() in build.gradle
  • Rebuild Haveno, updating the verification metadata for the new dependency: ./gradlew --write-verification-metadata sha256 && ./gradlew build --refresh-keys --refresh-dependencies -x test -x checkstyleMain -x checkstyleTest
  • Start Haveno with --useNativeXmrWallet=true

You could make some change in monero-java to confirm the update however you do it, e.g. adding std::cout << "getting balance!" << std::endl; to uint64_t monero_wallet_full::get_balance() const in monero_wallet_full.cpp.

@nsec1
Copy link
Contributor

nsec1 commented Jun 27, 2024

@woodser , could you check?
woodser/monero-cpp#64
woodser/monero-java#105

@nsec1
Copy link
Contributor

nsec1 commented Jul 13, 2024

@woodser, could you check woodser/monero-java#105?

@KewbitXMR
Copy link

Is this still outstanding? Anyone currently working on it?

nsec1 added a commit to nsec1/monero-java that referenced this issue Jul 17, 2024
…let on ubuntu 20, 22 and debian 12)

- using openssl and unbound static libs
- using boost (1.71.0) as module and building it static with -fPIC

Ref. woodser#74 haveno-dex/haveno#795
@woodser
Copy link
Contributor Author

woodser commented Aug 20, 2024

Is this still outstanding? Anyone currently working on it?

It's being worked on by @nsec1 here: woodser/monero-java#105

@KewbitXMR
Copy link

Is this actively being worked on?

@woodser
Copy link
Contributor Author

woodser commented Aug 22, 2024

Yes, @nsec1 has new changes I need to test: woodser/monero-java#105 (comment)

@woodser woodser changed the title Build monero-java and monero-cpp to static libraries with shared library wrapper [3 XMR] Build monero-java and monero-cpp to static libraries with shared library wrapper [4 XMR] Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💰bounty There is a bounty on this issue
Projects
None yet
Development

No branches or pull requests

6 participants