knowsys / rulewerk

Java library based on the VLog rule engine
Apache License 2.0
32 stars 13 forks source link

Standalone client on M1 Mac produce this error: (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) #220

Closed a-alhazmi closed 1 year ago

a-alhazmi commented 2 years ago

Hello, I am PhD student, who working on ForBackBench project. I am using Rulewerk as a standalone client in my project. The client jar file working perfectly on Linux and Mac with Intel processors.

At some point, I tried to run the client on the new M1 Mac (Mac with architecture arm64) , but I got that error: Exception in thread "main" java.lang.UnsatisfiedLinkError: while loading kognac-core: /private/var/folders/nk/mg7msvvx4rg7d9bht0l7lnwr0000gp/T/VLog-tmp6815360794293855698/libkognac-core.dylib: dlopen(/private/var/folders/nk/mg7msvvx4rg7d9bht0l7lnwr0000gp/T/VLog-tmp6815360794293855698/libkognac-core.dylib, 0x0001): tried: '/private/var/folders/nk/mg7msvvx4rg7d9bht0l7lnwr0000gp/T/VLog-tmp6815360794293855698/libkognac-core.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libkognac-core.dylib' (no such file) I downloaded the code again and tried to using the build-vlog-library.sh to build new client on the M1 Mac, but the error is still exist.

How could I run the standalone client on M1 Mac?

irina-dragoste commented 2 years ago

Hello. This is a VLog bug. I link it here: Issue 96 Did you try updating the VLog dependency version in the rulewerk-vlog pom.xml file prior to running build-vlog-library.sh ? Perhaps if not, maven could use the old dependency and not the newly built one.

In case you did, did you get this error when trying to build VLog, or did it build successfully?

a-alhazmi commented 2 years ago

Hello, Thanks for your answer.

The Vlog dependency version in therulewerk-vlog pom.xml file is: <karmaresearch.vlog.version>1.3.5</karmaresearch.vlog.version> , which match the Vlog release that in Vlog GitHub.

It built successfully without any errors, but when I run the client jar file it throws that error (incompatible architecture).

irina-dragoste commented 2 years ago

We see that the released karmaresearch.vlog (vlog-java) jar version 1.3.5 does not work on M1 Mac, as you reported in this issue. Thank you for finding it! I linked it to the related VLog issue.

We want to see if the current main branch in VLog that is built on M1 Mac can run there successfully. When running build-vlog-library.sh, this builds a new VLog (specifically, vlog-java.jar) and places it in your local maven repository, with the version given by <karmaresearch.vlog.version> property. To make sure the newly built vlog-java.jar is used, it is recommended to follow the steps below:

Does the bug still occur when following these steps?

irina-dragoste commented 2 years ago

Also, what command issues this error? We want to make sure we can reproduce the bug.

a-alhazmi commented 2 years ago

Yes, I followed all these steps, and the error was there. The error was thrown not from build commands, it was from running the produced stand-alone jar file.

Exception in thread "main" java.lang.UnsatisfiedLinkError: while loading kognac-core: /private/var/folders/nk/mg7msvvx4rg7d9bht0l7lnwr0000gp/T/VLog-tmp164877341971675468/libkognac-core.dylib: dlopen(/private/var/folders/nk/mg7msvvx4rg7d9bht0l7lnwr0000gp/T/VLog-tmp164877341971675468/libkognac-core.dylib, 0x0001): tried: '/private/var/folders/nk/mg7msvvx4rg7d9bht0l7lnwr0000gp/T/VLog-tmp164877341971675468/libkognac-core.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libkognac-core.dylib' (no such file)
    at karmaresearch.vlog.VLog.loadLibrary(VLog.java:72)
    at karmaresearch.vlog.VLog.<clinit>(VLog.java:22)
    at org.semanticweb.rulewerk.reasoner.vlog.VLogReasoner.<init>(VLogReasoner.java:82)
    at org.semanticweb.rulewerk.client.picocli.RulewerkClientMaterialize.run(RulewerkClientMaterialize.java:102)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1729)
    at picocli.CommandLine.access$900(CommandLine.java:145)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2101)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2068)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1935)
    at picocli.CommandLine.execute(CommandLine.java:1864)
    at org.semanticweb.rulewerk.client.picocli.Main.main(Main.java:77)

The good news the problem is resolved. Here what I did:

And it worked.

CerielJacobs commented 2 years ago

This issue can probably be fixed by providing "universal" binaries for the Mac (these work for i386 as well as arm64). I'm looking into how to do this.

irina-dragoste commented 2 years ago

@a-alhazmi, Could you please try again on M1 Mac with the provided VLog jar attached in try-solve-vlog-bug-96.zip? This .zip archive contains a jar with "universal binaries" for Mac, but we didn't have access to an M1 Mac to test it ourselves.

  1. extract jvlog-local.jar file from .zip, and save it in rulewerk-vlog\lib folder
  2. increase <karmaresearch.vlog.version>1.3.5</karmaresearch.vlog.version> version in rulewerk-vlog\pom.xml file
  3. run mvn initialize -Pdevelopment from rulewerk-parent dir
  4. run mvn clean install
  5. run what reasoning task was causing this bug before.
irina-dragoste commented 1 year ago

fixed here: https://github.com/karmaresearch/vlog/issues/96