C dependency management with DUB
I tested DUB and I wanted to install derelcitsdl2 using
"dependencies": { "derelict-sdl2": ">=1.2.10" } But it immediately throws a runtime error when I run it. He tells me that he cannot find * .so files.
When I create a cross-platform project, I do not want this to depend on global system packages, and this is likely to be a problem for Windows.
Can I run scripts from a DUB?
Something that might look like this
"dependencies": { "derelict-sdl2": ">=1.2.10" } "c-dependency-sdl":{ git clone sdllink && cd sdl && cmake . && make && make install clib } I did not find any information on the DUB website that tells me that this is most likely impossible.
How do you create your projects for different platforms?
Do I need to write .sh / .bat scripts for this? How to specify a local search path?
As far as I know, dub does not handle dependency installations without duplication. You can describe the requirements for the system library using the systemDependencies , which will be "visible in the registry and will be displayed in case of linker errors", but they will not be installed automatically.
You can use preGenerateCommands or preBuildCommands to execute shell commands as described above. I would put the installation scripts in the .sh / .bat script as you described above (so that they are suitable for users without duplication), and then put something like this in dub.json :
"preGenerateCommands-posix": [ "./setup.sh" ], "preGenerateCommands-windows": [ "./setup.bat" ] In linux, I usually assumed that the necessary .so files are available on the standard search path (or available for installation through the package manager), especially for something in common, such as sdl.
As for specifying the search path, I just use lflags :
"lflags": [ "-L./ext/sdl/lib" ] (or wherever the local libs are) Sources: DUB Package Format
Full disclosure: I have not actually tried to use preGenerateCommands , but this seems like what you need.
For what it's worth, I move on to this problem and use make / gmake to create a top-level assembly. This handles C / C ++ dependencies (which in my case are installed in / usr / local / lib and / usr / local / include) and uses Dub to build parts of the D language (referring to the dependency path as lflags in dub.json) .