digitalmars.D.learn - DUB: link to local library
- rcor (37/37) Sep 10 2014 I'd like to link to DAllegro5, which doesn't have an official dub
- Edwin van Leeuwen (5/11) Sep 10 2014 Does adding:
I'd like to link to DAllegro5, which doesn't have an official dub package yet. My project structure looks like this: ------------------------------ ext/ dallegro5/ allegro5/ <---- d bindings that need to be imported libdallegro5.a <-- library I need to link to src/ app.d <---- single source file which uses DAllegro5 bindings dub.json ------------------------------ app.d is just the DAllegro5 example: https://github.com/SiegeLord/DAllegro5/blob/master/example.d I can build a working executable with the following command: dmd -Iext/dallegro5 -L-Lext/dallegro5 src/app.d dub.json contains what I think should do the same as above: { "name": "test", "importPaths": ["ext/dallegro5"], "lflags": ["-Lext/dallegro5"] } Obviously this is missing some fields that I would want in a full project like authors and license but I'm trying to keep it simple until I figure out dub. dub.json seems like it should add the import and library search paths just like the dmd command I used, but instead fails with linker errors: .dub/build/application-debug-linux.posix-x86_64-dmd-323FC98A6F20DD1891F81CB0FEE1D200/test o:(.rodata+0x1ba8): undefined reference to `_D8allegro57allegro12__ModuleInfoZ' ... a few more of these, followed by: .../test/src/app.d:39: undefined reference to `al_init' ... and many more undefined references Does anyone have an idea of how to make this work? I can push this test project structure up on a git repo if it would help to see the whole thing.
Sep 10 2014
On Wednesday, 10 September 2014 at 13:40:16 UTC, rcor wrote:dub.json contains what I think should do the same as above: { "name": "test", "importPaths": ["ext/dallegro5"], "lflags": ["-Lext/dallegro5"] }Does adding: "libs": ["dallegro5"] make a difference? Cheers, Edwin
Sep 10 2014
Dub command line supports something like Dub add-local. Then you can use the package directly. Kind regards Andre On Wednesday, 10 September 2014 at 15:40:11 UTC, Edwin van Leeuwen wrote:On Wednesday, 10 September 2014 at 13:40:16 UTC, rcor wrote:dub.json contains what I think should do the same as above: { "name": "test", "importPaths": ["ext/dallegro5"], "lflags": ["-Lext/dallegro5"] }Does adding: "libs": ["dallegro5"] make a difference? Cheers, Edwin
Sep 10 2014
On Wednesday, 10 September 2014 at 16:26:07 UTC, andre wrote:Dub command line supports something like Dub add-local. Then you can use the package directly. Kind regards AndreDAllegro5 doesn't have an official dub package yet, but I threw together one that could build the library and added it with `dub add-local`. It now shows up in `dub list`, but adding: "dependencies": { "dallegro5": "~master" } doesn't seem to change anything. I think the dub.json I put in dallegro5 works, because the library it produces can be used to run the example with dmd.
Sep 10 2014
DAllegro5 doesn't have an official dub package yet, but I threw together one that could build the library and added it with `dub add-local`. It now shows up in `dub list`, but adding: "dependencies": { "dallegro5": "~master" }I think I recently saw something like: "dependencies": { "dallegro5": { "version": "~master", "path": "../path/to/your/lib" } } Although I haven't tried it yet. Bye, Jeroen
Sep 10 2014
I think I recently saw something like: "dependencies": { "dallegro5": { "version": "~master", "path": "../path/to/your/lib" } } Although I haven't tried it yet. Bye, JeroenI believe you're talking about this: https://github.com/D-Programming-Language/dub/issues/119 and unfortunately it doesn't seem to help.
Sep 10 2014
Finally got it: { "name": "test", "importPaths": ["ext/dallegro5"], "lflags": ["-Lext/dallegro5"], "libs": [ "allegro", "allegro_acodec", "allegro_audio", "allegro_font", "allegro_ttf", "allegro_image", "allegro_color", "allegro_primitives" ], "dependencies": { "dallegro5": "~master" } } I had to specify the C libs for allegro and its addons. Also, specifying dallegro5 as a dependency does seem to be necessary (this is after adding with `dub add local`). Thanks for all the suggestions.
Sep 11 2014
On Wednesday, 10 September 2014 at 15:40:11 UTC, Edwin van Leeuwen wrote:On Wednesday, 10 September 2014 at 13:40:16 UTC, rcor wrote:I thought libs was for linking to system libraries, which dallegro5 isn't (its just built locally and not installed system-wide). However, "libs": ["dallegro5"] does seem to change the errors a bit: Without: http://pastebin.com/Xpq94EkR With: http://pastebin.com/7fet3xU1 In particular, it makes the undefined reference to al_init disappear, so maybe its a step in the right direction. Allegro divides its functionality into several modules -- when I was using C I would have to specify each of these libs, which I would get from pkgconfig. I wonder if I need to do that here, but it wasn't necessary when I was building with dmd alone.dub.json contains what I think should do the same as above: { "name": "test", "importPaths": ["ext/dallegro5"], "lflags": ["-Lext/dallegro5"] }Does adding: "libs": ["dallegro5"] make a difference? Cheers, Edwin
Sep 10 2014