libzt icon indicating copy to clipboard operation
libzt copied to clipboard

java windows does not compile dll

Open 04041b opened this issue 2 years ago • 16 comments

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.

04041b avatar Dec 29 '23 23:12 04041b

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.

MegumiKasuga avatar May 18 '24 15:05 MegumiKasuga

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

04041b avatar May 25 '24 17:05 04041b

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 avatar May 25 '24 17:05 MegumiKasuga

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

MegumiKasuga avatar May 25 '24 17:05 MegumiKasuga

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 avatar May 26 '24 06:05 04041b

@MegumiKasuga

04041b avatar May 26 '24 06:05 04041b

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

MegumiKasuga avatar May 26 '24 07:05 MegumiKasuga

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

MegumiKasuga avatar May 26 '24 07:05 MegumiKasuga

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());

04041b avatar May 26 '24 07:05 04041b

They are just the same. image @04041b

MegumiKasuga avatar May 26 '24 07:05 MegumiKasuga

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.

MegumiKasuga avatar May 26 '24 10:05 MegumiKasuga

just in case anyone stumble on this issue I'm going to leave it open until the issue is fixed with scripts https://github.com/zerotier/libzt/issues/267#issuecomment-2132084509

04041b avatar May 27 '24 23:05 04041b

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

MegumiKasuga avatar May 28 '24 03:05 MegumiKasuga

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.

04041b avatar May 28 '24 08:05 04041b

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

MegumiKasuga avatar May 28 '24 08:05 MegumiKasuga

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"

04041b avatar Jun 02 '24 02:06 04041b