zerotier / libzt

Encrypted P2P sockets over ZeroTier
https://zerotier.com
Other
166 stars 51 forks source link

java windows does not compile dll #267

Open 04041b opened 6 months ago

04041b commented 6 months ago

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 commented 2 months ago

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, andMAC,nodeID``` are correct, which seems to be wried.

Maybe it would be useful for you.

04041b commented 2 months ago

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, andMAC,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 commented 2 months ago

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 commented 2 months ago

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

04041b commented 1 month ago

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 commented 1 month ago

@MegumiKasuga

MegumiKasuga commented 1 month ago

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

MegumiKasuga commented 1 month ago

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

04041b commented 1 month ago

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 commented 1 month ago

They are just the same. image @04041b

MegumiKasuga commented 1 month ago

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 commented 1 month ago

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

MegumiKasuga commented 1 month ago

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

04041b commented 1 month ago

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 commented 1 month ago

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

04041b commented 1 month ago

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"