Alloy API resulting in java.lang.UnsatisfiedLinkError

后端 未结 2 1082
生来不讨喜
生来不讨喜 2021-01-24 03:33

I\'m currently using the Alloy Analyzer API to build a program, and getting some peculiar behavior. Specifically, if I open a file and parse it (using CompUtil.parseEverything),

相关标签:
2条回答
  • 2021-01-24 04:06

    I use alloy4.2.jar as a library in my eclipse plugin project.

    A4Reporter rep = new A4Reporter();
    Module world = CompUtil.parseEverything_fromFile(rep, null, "civi.als");
    A4Options options = new A4Options();
    options.solver = A4Options.SatSolver.SAT4J;
    options.skolemDepth = 1;
    

    When I use SAT4J, the default solver, the problem mentioned here will not show up. But another exception comes out. The reason is that my civi.als file need Integer model, which located in alloy4.2.jar under the folder /models/util/. But when I run the application, it tries to find the file util/Integer.als directly. That causes the exception. Is it possible to fix that problem?

    Besides, I also tried to put the alloy4.2.jar in eclipse plugin project and run my application as an eclipse application (running my application as a plugin). With the default solver, the application has no problem at all. But when I switch to MiniSatProverJNI, the problem mentioned here comes out (I have set the alloy4.2.jar as classpath).

    0 讨论(0)
  • 2021-01-24 04:27

    I tried to reproduce this behavior, but I couldn't. If I don't add MiniSat binaries to the LD_LIBRARY_PATH environment variable, I get the exception you mentioned the very first time I invoke execute_command. After configuring LD_LIBRARY_PATH, the exception doesn't happen.

    To configure LD_LIBRARY_PATH:

    (1) if using Eclipse, you can right-click on one of your source folders, choose Build Path -> Configure Build Path, then on the "Source" tab make sure that "Native library location" points to a folder in which MiniSat binaries reside.

    (2) if running from the shell, just add the path to a folder with MiniSat binaries to LD_LIBRARY_PATH, e.g., something like export LD_LIBARRY_PATH=alloy/extra/x86-linux:$LD_LIBRARY_PATH.

    Here is the exact code that I was running, and everything worked

    public static void main(String[] args) throws Exception {
        A4Reporter rep = new A4Reporter();
    
        A4Options options = new A4Options();
        options.solver = A4Options.SatSolver.MiniSatProverJNI;
    
        Module someWorld = CompUtil.parseEverything_fromFile(rep, null, "someFile.als");
        Command command = someWorld.getAllCommands().get(0);
        A4Solution ans = TranslateAlloyToKodkod.execute_command(rep, someWorld.getAllReachableSigs(), command, options);
        System.out.println(ans);
    
        Module someOtherWorld = CompUtil.parseEverything_fromFile(rep, null, "someOtherFile.als");
        Command commandTwo = someOtherWorld.getAllCommands().get(0);
        A4Solution ansTwo = TranslateAlloyToKodkod.execute_command(rep, someOtherWorld.getAllReachableSigs(), commandTwo, options);
        System.out.println(ansTwo);
    }
    

    with "someFile.als" being

    sig A {}
    run { some A } for 4
    

    and "someOtherFile.als"

    sig A {}
    run { no A } for 4
    
    0 讨论(0)
提交回复
热议问题