5

我正在测试配音,我想安装 derelcitsdl2

"dependencies": {
   "derelict-sdl2": ">=1.2.10"
}

但是当我运行它时它会立即引发运行时错误。它告诉我它找不到 *.so 文件。

当我构建一个跨平台项目时,我不想依赖这样的全局系统包,这很可能是 Windows 上的一个问题。

是否可以使用 DUB 运行构建脚本?

看起来像这样的东西

"dependencies": {
   "derelict-sdl2": ">=1.2.10"
}
"c-dependency-sdl":{
   git clone sdllink && cd sdl && cmake . && make && make install clib
 }

我在 DUB 网站上没有找到告诉我这很可能是不可能的信息。

您如何为不同的平台构建项目?

我需要为此编写 .sh / .bat 脚本吗?我将如何指定本地搜索路径?

4

2 回答 2

5

As far as I know, dub does not handle the installation of non-dub dependencies. You can describe system library requirements with the systemDependencies entry, which will be "visible on the registry and will be displayed in case of linker errors", but they will not be installed automatically.

You could use preGenerateCommands or preBuildCommands to execute shell commands like you described above. I would put the install scripts in .sh/.bat scripts like you described above (so they are useable for non-dub users), and then place something like this in dub.json:

"preGenerateCommands-posix":   [ "./setup.sh"  ],
"preGenerateCommands-windows": [ "./setup.bat" ]

On linux, I would typically assume the necessary .so files are available on the standard search path (or available for install through a package manager), especially for something common like sdl.

As far as specifying search path, I just use lflags:

"lflags": [ "-L./ext/sdl/lib" ] (or wherever the local libs are)

Sources: DUB Package Format

Full Disclosure: I haven't actually tried using preGenerateCommands, but it sounds like what you need.

于 2014-12-28T02:42:34.867 回答
1

对于它的价值,我解决了这个问题并使用 make/gmake 来驱动顶级构建。这将处理 C/C++ 依赖项(在我的情况下安装到 /usr/local/lib 和 /usr/local/include 中)并使用 Dub 构建 D 语言部分(将依赖项路径引用为 dub.json 中的 lflags )。

于 2015-02-16T14:45:37.143 回答