Closed Frooastside closed 1 year ago
I just confirmed that it only occurs, if I use a module-info
and the issue is not based on different problems
I also noticed that the physx.vehicle2
package is not included in the module-info
Also as it is not possible to declare the same package in separate modules (de.fabmax.physicsjni
where the NativeMeta classes are located), I thought of putting them in a sub directory like de.fabmax.physicsjni.linux.NativeMetaLinux
. Also, is it actually necessary to have that class separate, loaded by Reflection? Because I would like to be able to load the libraries (.so, .dylib, .dll) from an arbitrary location and not from the class path if that would be possible.
Ah yes, I'm not using java modules myself so I haven't noticed that this actually isn't working, but I was able reproduced your problem.
Putting the native classes in separate packages / modules should not be a problem but I will keep the reflection based loading. I think that is the easiest method to maintain drop-in compatibility between the regular and cuda versions and also to check if the versions of the main lib and the native lib match.
However, it should already be possible to specify a custom path by setting the system properties physx.nativeLibLocation=/path/to/libraries/
and physx.skipHashCheck=true
(I will probably change these in the next version to something a bit more intuitive).
Ok thank you, I noticed the code for physx.nativeLibLocation
to but didn't realize that it never actually tried to use that because of the different error.
Doesn't this code require it to be in the class path, like even if it allows me to load it from an arbitrary location, isn't it still required to be there?
private static void loadLibsFromResources(List<String> libResourceNames) throws IOException {
...
for (String libResource : libResourceNames) {
InputStream libIn = Loader.class.getClassLoader().getResourceAsStream(libResource);
if (libIn == null) {
throw new IllegalStateException("Failed loading " + libResource + " from resources");
}
Yes you are right, nevermind 😃
Anyway, now it should actually work by setting physxjni.loadFromResources=false
and specifying the library path with physxjni.nativeLibLocation=path/to/libraries/
(see here). The module stuff should be fixed as well.
I published a new snapshot containing the changes: https://oss.sonatype.org/content/repositories/snapshots/de/fabmax/physx-jni/2.0.6-SNAPSHOT/
Works now, thank you. Some thing to remember is that to include it in the module-info
it needs to be implementation
instead of runtimeOnly
or it will not be recognizable and they always need to be all in the gradle configuration at the same time but if you intend to bundle it and only include the necessary binaries, these few extra NativeLib
classes are not a problem. But I also noticed that the libraries are now duplicated. For me that's not really a problem just wanted to mention it, because it's probably not intended.
Some thing to remember is that to include it in the
module-info
it needs to beimplementation
instead ofruntimeOnly
Yes I noticed that as well. Apparently there is no requiresRuntime
or something like that in the module-info.
But I also noticed that the libraries are now duplicated.
Thanks, I missed that. Will remove it with the next build.
I think i will close this now, as my main issue is resolved, thanks a lot!
In my build.gradle file, i both included the base library and natives with
and when running just the initialization:
I get the error
Caused by: java.lang.IllegalStateException: Failed loading native PhysX libraries for platform LINUX
and the cause of that isCaused by: java.lang.ClassNotFoundException: de.fabmax.physxjni.NativeMetaLinux
. I think this is because of the native library not having amodule-info.class
. I am also not able to manually import theNativeMetaLinux
class due to that.my
module-info.class
looks like thatfull error log: