我遇到了从Scala程序调用外部程序(特别是SAT求解器Picosat)的问题。
具体来说,问题是当从ScalaIDE调用Picosat时系统返回“非零退出值:-1073741515”的“java.lang.RuntimeException”,尽管从(Cygwin)终端调用它时系统工作。
作为示例,此问题的最小代码示例如下:
import sys.process._
object Hello {
def main(args: Array[String]): Unit = {
val result = "picosat -h".!!
println(result)
}
}
从ScalaIDE执行示例代码时,执行此示例代码将返回以下异常消息并退出:
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: -1073741515
at scala.sys.package$.error(package.scala:27)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:132)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:102)
at Hello$.main(Hello.scala:5)
at Hello.main(Hello.scala)
虽然它在从Cygwin执行示例代码时打印出Picosat的正确“帮助消息”,如下所示:
> scala src/Hello.scala
usage: picosat [ <option> ... ] [ <input> ]
where <option> is one of the following
-h print this command line option summary and exit
--version print version and exit
--config print build configuration and exit
-v enable verbose output
-f ignore invalid header
-n do not print satisfying assignment
-p print formula in DIMACS format and exit
--plain disable preprocessing (failed literal probing)
-a <lit> start with an assumption
...
如果您能为此问题提供任何线索,我将不胜感激?