【问题标题】:Running an or tools example in maven在 Maven 中运行或工具示例
【发布时间】:2020-06-19 11:09:09
【问题描述】:

我正在尝试在具有 or-tools 中最新的 maven 支持的 IDE 中运行示例。在 cmake 构建完成后(来自here 的指令)我可以在我的 .m2 文件夹中看到 jar 文件。我在我的项目中添加了以下依赖项

    <dependency>
        <groupId>com.google.ortools</groupId>
        <artifactId>ortools-java</artifactId>
        <version>7.7.7810</version>
    </dependency>

编译成功,但在运行程序时抛出以下错误

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniortools in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.walmartlabs.services.core.engine.ortools.OrToolSolver.<clinit>(OrToolSolver.java:13)

不应该添加依赖就足够了为什么它需要下面的外部库示例程序。

 public class OrToolSolver {
    static {
        System.loadLibrary("jniortools");
    }
    public static void main(String[] args) {
        // Create the linear solver with the CBC backend.
        MPSolver solver = new MPSolver("SimpleMipProgram", MPSolver.OptimizationProblemType.CBC_MIXED_INTEGER_PROGRAMMING);
    }

我可能遗漏了一些明显的东西。

【问题讨论】:

  • 我相信你需要告诉 maven 在哪里加载 jni 库。命令行上的类似 java.library.path 的东西。

标签: or-tools


【解决方案1】:

目前,我们不支持 maven,我们不构建任何 maven jar。它在计划中。

【讨论】:

    【解决方案2】:

    添加this 作为依赖项。当您尝试通过 Maven 构建 OR 工具时,这将使您的生活更轻松。

    【讨论】:

      猜你喜欢
      • 2022-01-19
      • 1970-01-01
      • 2012-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多