www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DUB Different Library Name

reply "serh" <cuznez gmail.com> writes:
Hello,

I am trying to use Derelict's Allegro 5 in my DUB project, 
however, when I try to run `dub build` it says it cannot find 
liballegro-5.0.11.so and liballegro-5.0.so.

I have both libraries installed as liballegro.so.5.0.11 and 
liballegro.so.5.0 under my Arch system respectively.

Is there a way to tell DUB that these are the libraries it must 
use without making ugly symlinks?
Jul 11 2015
parent reply "Mike Parker" <aldacron gmail.com> writes:
On Saturday, 11 July 2015 at 16:43:39 UTC, serh wrote:
 Hello,

 I am trying to use Derelict's Allegro 5 in my DUB project, 
 however, when I try to run `dub build` it says it cannot find 
 liballegro-5.0.11.so and liballegro-5.0.so.

 I have both libraries installed as liballegro.so.5.0.11 and 
 liballegro.so.5.0 under my Arch system respectively.

 Is there a way to tell DUB that these are the libraries it must 
 use without making ugly symlinks?
No Derelict package has a compile-time or link-time dependency on the libraries they bind. The libraries are loaded at run time. DUB doesn't know anything about those libraries, so you shouldn't be seeing such an error with 'dub build'. The only time you should see it is when trying to run the program. Could you please post the command line you used and the exact errors you're seeing?
Jul 11 2015
parent reply "serh" <cuznez gmail.com> writes:
On Sunday, 12 July 2015 at 01:17:27 UTC, Mike Parker wrote:
 No Derelict package has a compile-time or link-time dependency 
 on the libraries they bind. The libraries are loaded at run 
 time. DUB doesn't know anything about those libraries, so you 
 shouldn't be seeing such an error with 'dub build'. The only 
 time you should see it is when trying to run the program. Could 
 you please post the command line you used and the exact errors 
 you're seeing?
You are right, I am running dub run, I made a mistake in the original post. This is what I get when I run "dub" in the directory: http://codepad.org/BpnOHVSV As mentioned, I already have respective Allegro libs installed, but as liballegro.so.5.0 instead of liballegro-5.0.so and so on. The C++ linker sees them fine, but I am not sure how to make dmd/DUB see the correct libraries to link.
Jul 11 2015
next sibling parent reply "Mike Parker" <aldacron gmail.com> writes:
On Sunday, 12 July 2015 at 02:14:06 UTC, serh wrote:

 This is what I get when I run "dub" in the directory:
 http://codepad.org/BpnOHVSV

 As mentioned, I already have respective Allegro libs installed, 
 but as liballegro.so.5.0 instead of liballegro-5.0.so and so on.
 The C++ linker sees them fine, but I am not sure how to make 
 dmd/DUB see the correct libraries to link.
This has nothing to do with DMD, DUB, or linking :) Derelict loads the shared libraries at runtime through the system API (LoadLibrary on Windows and dlopen elsewhere). Each package has a default set of library names it looks for. I was under the impression that liballegro-x.x.so was the common form for Allegro, so either I was wrong or things are different on Arch. Regardless, the default library names can be overridden. Just past the library names you need in the call to load: ``` DerelictAllegro5.load("liballegro.so.5.0"); ``` That should do the trick for now. In the meantime, I'll update the loader to include this form in the default library name list as soon as I get the chance. Also, I recommend you take a look at the documentation for using Derelict at [1]. For future reference, when using DUB to manage a project, you need to be aware of the different kinds of error output. Sometimes it's from the compiler, sometimes from the linker, and sometimes from something that happened at run time. In your case, look at this line: derelict.util.exception.SharedLibLoadException ../../../.dub/packages/derelict-util-2.0.0/source/derelict/util/exception.d(35): The first part, 'derelict.util.exception.SharedLibLoadException' tells you that this is an exception being thrown by Derelict. That can only happen at run time. [1] http://derelictorg.github.io/using.html
Jul 11 2015
parent "serh" <cuznez gmail.com> writes:
On Sunday, 12 July 2015 at 05:18:24 UTC, Mike Parker wrote:
 This has nothing to do with DMD, DUB, or linking :) Derelict 
 loads the shared libraries at runtime through the system API 
 (LoadLibrary on Windows and dlopen elsewhere). Each package has 
 a default set of library names it looks for. I was under the 
 impression that liballegro-x.x.so was the common form for 
 Allegro, so either I was wrong or things are different on Arch.

 Regardless, the default library names can be overridden. Just 
 past the library names you need in the call to load:

 ```
 DerelictAllegro5.load("liballegro.so.5.0");
 ```

 That should do the trick for now. In the meantime, I'll update 
 the loader to include this form in the default library name 
 list as soon as I get the chance.
Thank you so much! Can't believe I missed that part of documentation. I am not sure if Allegro uses the same name under platforms different from Arch though.
Jul 11 2015
prev sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Sun, 12 Jul 2015 02:14:04 +0000, serh wrote:

 As mentioned, I already have respective Allegro libs installed, but as
 liballegro.so.5.0 instead of liballegro-5.0.so and so on.
 The C++ linker sees them fine, but I am not sure how to make dmd/DUB see
 the correct libraries to link.
Derelict doesn't do compile-time linking with libraries, it loads=20 libraries in runtime. rather controversal approach, but it seems to work=20 better for windows. the side effect of it is that: 1. build system can't use pkg-config (or another *-config) utility to=20 link with correct libraries. 2. if your library is old, and Derelict was written against newer with=20 some API added -- badaboom! even if you never used that new API. both problems are solvable, though. if you'll read Derelict documentation=20 (and, maybe, sources) hard enough, you'll find a way to tell Derelict=20 which library to load, and how to live with missing APIs. i can't give=20 you a direct link, though, as i'm not using Derelict, but i'm pretty sure=20 that it shouldn't be hard to find.=
Jul 11 2015