【问题标题】:Google Or-Tools : UnsatisfiedLinkError谷歌或工具:UnsatisfiedLinkError
【发布时间】:2025-12-28 18:45:11
【问题描述】:

我创建了一个使用 google or-tools 的 spring 应用程序。为此,我使用 System.loadLibrary("jniortools") 导入 jniortools。当我提供 .dll 文件并运行 war 文件时,它运行良好。但是当我在 lib 中提供 .so 文件路径时,我得到了 unsatisfiedlinkerror。

【问题讨论】:

    标签: java spring or-tools


    【解决方案1】:

    取自here,一个在 Intellij 上使用 or-tools 的解决方案:

    要使用 Intellij(通过 Windows 机器)使其工作,您需要:

    1. 安装Microsoft Visual C++ Redistributable for Visual Studio
    2. 下载并解压OR-Tools library for Java
    3. 在 intellij 中,add jar dependency 到解压文件的 lib 文件夹下的 2 个 jar 中(2 个 jar 中的每一个单独添加,不要添加到 lib 文件夹本身。This is why)。
    4. 将 lib 库路径添加到 VM 选项。在 Intellij 中编辑您的运行配置并添加到 vm 选项:-Djava.library.path=<path to the lib folder that hold the jars>
    5. 通过将以下代码添加到您的类来静态加载 jni 库(如提到的here。)

      static { System.loadLibrary("jniortools"); }

    【讨论】: