Skip to content

Commit

Permalink
Merge pull request #35 from eed3si9n/wip/native_lookup
Browse files Browse the repository at this point in the history
Fix the lookup of native library
  • Loading branch information
eed3si9n authored Dec 30, 2022
2 parents 1bc93de + e9b01e1 commit d182978
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/org/scalasbt/ipcsocket/NativeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ static void load() throws UnsatisfiedLinkError {
final boolean isLinux = os.startsWith("linux");
final boolean isWindows = os.startsWith("windows");
final boolean is64bit = System.getProperty("sun.arch.data.model", "64").equals("64");
String arch = System.getProperty("os.arch", "").toLowerCase();
if (arch.equals("amd64")) {
arch = "x86_64";
}
if (is64bit && (isMac || isLinux || isWindows)) {
final String extension = "." + (isMac ? "dylib" : isWindows ? "dll" : "so");
final String libName = (isWindows ? "" : "lib") + "sbtipcsocket" + extension;
final String prefix = isMac ? "darwin" : isLinux ? "linux" : "win32";

final String resource = prefix + "/x86_64/" + libName;
final String resource = prefix + "/" + arch + "/" + libName;
final URL url = NativeLoader.class.getClassLoader().getResource(resource);
if (url == null) throw new UnsatisfiedLinkError(resource + " not found on classpath");
try {
Expand Down

0 comments on commit d182978

Please sign in to comment.