Josenaldo
06/22/2024, 11:32 PMjvmArgs += "-Djava.library.path=%PATH%;C:\path\to\mylib"
in Windows, but when I load it with System.loadLibrary(libname)
, I get an UnsatisfiedLinkError. I'm trying to build an executable file with the createDistributable
gradle task from this Compose Multiplatform tutorial.
What I don't understand is why System.getProperty("java.library.path")
results in %PATH%;C:pathtomylib
, without backslashes and without %PATH%
being actually resolved. I want the property to be the content of PATH together with the path to my lib, i.e. something like C:\path\one;C:\path\two;C:\path\to\mylib
.
I found out that surrounding the final path with quotes ("-Djava.library.path="\"%PATH%;C:\path\to\mylib\""
) brings back backslashes, but the issue with %PATH%
persists. The next attempt was "-Djava.library.path="\"${System.getenv("PATH")};C:\path\to\mylib\""
, but then the createDistributable
task itself threw a TaskExecutionException, with the error log being Error: Invalid Option: [Files\Git\cmd;C:\Users\tempj\AppData\Local\Microsoft\WindowsApps;;C:\path\to\mylib']
(I suspect that the single quote at the end might be the culprit, but I myself didn't insert it...).Josenaldo
06/22/2024, 11:51 PMC:\path\to\mylib
, so that's why I'm attempting to set the library path to PATH + the path to the lib.ephemient
06/23/2024, 12:20 AMMichael Paus
06/23/2024, 10:24 AMSystem.getProperty("compose.application.resources.dir")?.let { System.setProperty("java.library.path", "${System.getProperty("java.library.path")}${File.pathSeparator}${it}") }
In your case the library should be placed in
desktopApp/resources/windows-x64/yourlibrary.dll