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

java windows does not compile dll #267

Open
04041b opened this issue Dec 29, 2023 · 16 comments
Open

java windows does not compile dll #267

04041b opened this issue Dec 29, 2023 · 16 comments

Comments

@04041b
Copy link

04041b commented Dec 29, 2023

image

After running command build.sh host-jar on my windows, the jar is only 20 kb, contains no dll file to be extract via
jar xf *.jar libzt.dll

image
In successful build on mac there should be a library included in the jar file.
The build.sh script is broken on windows.

@MegumiKasuga
Copy link

You could use
. .\build.ps1; Build-Library -BuildType "Release" -Arch "x64" -LangBinding "java"
to get the lib separately (for windows).

I use this way to get my lib but it still has some problem.
It would be not able to get our IPv4 and IPv6 addresses correctly (My test program returns me both 127.0.0.1, and the return of native method are both (empty))
By the way it could connect to the virtural network, and MAC, nodeID are correct, which seems to be wried.

Maybe it would be useful for you.

@04041b
Copy link
Author

04041b commented May 25, 2024

You could use . .\build.ps1; Build-Library -BuildType "Release" -Arch "x64" -LangBinding "java" to get the lib separately (for windows).

I use this way to get my lib but it still has some problem. It would be not able to get our IPv4 and IPv6 addresses correctly (My test program returns me both 127.0.0.1, and the return of native method are both (empty)) By the way it could connect to the virtural network, and MAC, nodeID are correct, which seems to be wried.

Maybe it would be useful for you.

Thank you, but I'm looking for a dll file I can import in my java program.
using the command . .\build.ps1; Build-Host -BuildType "Release" -Arch "x64" yields you a libzt.dll and libzt.lib, but the dll file just don't work

@MegumiKasuga
Copy link

You could see #277 for more info. before import you may rename your dll to zt.dll, cause the jar source code was written to load that.
See here

@MegumiKasuga
Copy link

If you can reproduce the results of my test in #277, please reply, thank you

@04041b
Copy link
Author

04041b commented May 26, 2024

It works!!!
image
All I change is from s_addr to S_addr in #277 and the nlohmann/json fix in #263
Here's the step I made it work
Apply the fix above, my fork with the fix: https://github.com/04041b/libzt
clone it, and git submodule update --init
run ./build.sh host-jar in git bash and . .\build.ps1; Build-Library -BuildType "Release" -Arch "x64" -LangBinding "java" in powershell
copy dist\win-x64-jni-release\lib\libzt.dll and rename it to zt.dll
copy dist-x64-jar-release\pkg\libzt-1.8.10.jar to your project

let me know if this works for you

@04041b
Copy link
Author

04041b commented May 26, 2024

@MegumiKasuga

@MegumiKasuga
Copy link

MegumiKasuga commented May 26, 2024

Glad to see your success. However my program's bugs remained, even in the situation using your fork.
ip

@MegumiKasuga
Copy link

See Here:
the native method just returns "".
bug

@04041b
Copy link
Author

04041b commented May 26, 2024

See Here: the native method just returns "". bug

I did not use native method
I use

ZeroTierNode node = new ZeroTierNode();
    System.out.println(node.getIPv4Address(networkId).getHostAddress());

@MegumiKasuga
Copy link

They are just the same.
image
@04041b

@MegumiKasuga
Copy link

I have finally fixed all bugs. The reason is that my JVM used an old version of zt.dll lies in my $PATH, which is a broken one. And libzt only supports one socket on one node. Here's my final test.
Server side:
image
Client side:
image
I successfully sent Hello from java! from C to S.

@04041b
Copy link
Author

04041b commented May 27, 2024

just in case anyone stumble on this issue I'm going to leave it open until the issue is fixed with scripts
#267 (comment)

@MegumiKasuga
Copy link

Maybe we could fix the jar documents. This problem has stuck me for years from using the lib.

@04041b
Copy link
Author

04041b commented May 28, 2024

The thing is I have no idea with the change in JavaSockets.cxx because I don't know c++. The change is a required fix to build. I don't want to have a pull request that contains changes I don't even know.

Maybe we could fix the jar documents. This problem has stuck me for years from using the lib.

@MegumiKasuga
Copy link

Maybe giving suggestions in if would be a good way. These if could be useful for others using this project.

@04041b
Copy link
Author

04041b commented Jun 2, 2024

Maybe giving suggestions in if would be a good way. These if could be useful for others using this project.

i don't quite understand what you mean by "if"

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