haveno icon indicating copy to clipboard operation
haveno copied to clipboard

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

Open woodser opened this issue 1 year ago • 32 comments

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: https://github.com/woodser/monero-java/issues/74

woodser avatar Feb 25 '24 13:02 woodser

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.

github-actions[bot] avatar Feb 25 '24 13:02 github-actions[bot]

I just saw this had been reopened. What is the issue?

On Tue, Apr 2, 2024, 1:35 PM woodser @.***> wrote:

Reopened #795 https://github.com/haveno-dex/haveno/issues/795.

— Reply to this email directly, view it on GitHub https://github.com/haveno-dex/haveno/issues/795#event-12325136481, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2MWRYYNG5NOE5QNS7SS6DY3KQX5AVCNFSM6AAAAABDY3WFJOVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGMZDKMJTGY2DQMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

niyid avatar Apr 05 '24 09:04 niyid

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.

woodser avatar Apr 05 '24 10:04 woodser

It seems MSYS2 is open source? Have you built it along with other dependencies from source into static libraries?

On Fri, Apr 5, 2024, 11:28 AM woodser @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/haveno-dex/haveno/issues/795#issuecomment-2039443798, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2MWR4ZKMKUHTM7QR45Q63Y3Z4GNAVCNFSM6AAAAABDY3WFJOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZZGQ2DGNZZHA . You are receiving this because you commented.Message ID: @.***>

niyid avatar Apr 05 '24 10:04 niyid

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

woodser avatar Apr 05 '24 11:04 woodser

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.

niyid avatar Apr 05 '24 19:04 niyid

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.

woodser avatar Apr 05 '24 19:04 woodser

I would like to look into this

mcneb10 avatar Apr 26 '24 03:04 mcneb10

@mcneb10 Great!

woodser avatar Apr 27 '24 12:04 woodser

@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 avatar Jun 23 '24 17:06 woodser

Bounty bumped to 3 XMR.

woodser avatar Jun 23 '24 17:06 woodser

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.

mcneb10 avatar Jun 23 '24 17:06 mcneb10

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

woodser avatar Jun 23 '24 17:06 woodser

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

woodser avatar Jun 23 '24 17:06 woodser

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

preland avatar Jun 23 '24 18:06 preland

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.

woodser avatar Jun 23 '24 18:06 woodser

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

mcneb10 avatar Jun 23 '24 19:06 mcneb10

@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?

nsec1 avatar Jun 26 '24 15:06 nsec1

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.

woodser avatar Jun 26 '24 15:06 woodser

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

nsec1 avatar Jun 27 '24 23:06 nsec1

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

nsec1 avatar Jul 13 '24 12:07 nsec1

Is this still outstanding? Anyone currently working on it?

KewbitXMR avatar Jul 15 '24 02:07 KewbitXMR

Is this still outstanding? Anyone currently working on it?

It's being worked on by @nsec1 here: https://github.com/woodser/monero-java/pull/105

woodser avatar Aug 20 '24 16:08 woodser

Is this actively being worked on?

KewbitXMR avatar Aug 22 '24 12:08 KewbitXMR

Yes, @nsec1 has new changes I need to test: https://github.com/woodser/monero-java/pull/105#issuecomment-2303096985

woodser avatar Aug 22 '24 12:08 woodser

It's been a while and what's the progress till now?

fxrstor avatar Jan 26 '25 14:01 fxrstor

@woodser ping. Still being worked on?

fxrstor avatar Jan 31 '25 02:01 fxrstor

@woodser ping 2. Still being worked on?

fxrstor avatar Feb 03 '25 16:02 fxrstor

Yes, I still need to test the latest solution, and it will still require more work. It just hasn't been a priority lately.

woodser avatar Feb 04 '25 00:02 woodser

https://github.com/woodser/monero-cpp/pull/80 and https://github.com/woodser/monero-java/pull/120 address this issue.

NorrinRadd avatar Mar 17 '25 21:03 NorrinRadd