www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - -L-ldl needed on Linux

reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Just wondering why I have to give dsss the -L-ldl flag manually when I 
compile a Derelict-using program under Linux.

Seems like it shouldn't be neecessary for me to have to specify that. 
But who's to blame?
* Is it DMD's fault for not including in the default link libs?
* Is it DSSS's fault for not picking up that it's needed (or for not 
puttin it in the default list of flags?)
* Is it Derelict's fault for somehow not telling DSSS that it wants to 
use libdl on Linux?

Any of those seem possible.  So anyone know the answer?

Or is it just my fault for thinking I shouldn't have to stick a 
version(linux) block in my dsss.conf file?

--bb
Apr 12 2008
next sibling parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
Isn't this what the "lib" pragma is for, if you don't want to have to 
pass it?

-[Unknown]


Bill Baxter wrote:
 Just wondering why I have to give dsss the -L-ldl flag manually when I 
 compile a Derelict-using program under Linux.
 
 Seems like it shouldn't be neecessary for me to have to specify that. 
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not 
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants to 
 use libdl on Linux?
 
 Any of those seem possible.  So anyone know the answer?
 
 Or is it just my fault for thinking I shouldn't have to stick a 
 version(linux) block in my dsss.conf file?
 
 --bb

Apr 12 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Unknown W. Brackets wrote:
 Isn't this what the "lib" pragma is for, if you don't want to have to 
 pass it?

I suppose so (or "link" pragma using dsss/bud). So you're saying it could be considered "Derelict's fault" for not providing that pragma. On Windows, the equivalent libs (containing LoadLibraryA/FreeLibrary/GetProcAddress) seem to be linked by default, by someone in the toolchain. DMD or DSSS, I'm not sure which. So it seems reasonable that it should be there by default under Linux, too.
 -[Unknown]
 
 
 Bill Baxter wrote:
 Just wondering why I have to give dsss the -L-ldl flag manually when I 
 compile a Derelict-using program under Linux.

 Seems like it shouldn't be neecessary for me to have to specify that. 
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not 
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants to 
 use libdl on Linux?

 Any of those seem possible.  So anyone know the answer?

 Or is it just my fault for thinking I shouldn't have to stick a 
 version(linux) block in my dsss.conf file?

 --bb


Apr 12 2008
next sibling parent reply Tower Ty <towerty msn.com.au> writes:
Bill Baxter Wrote:

 Unknown W. Brackets wrote:

I'm interested here in understanding another difference between Linux and Windows. Chris Miller used Entice Designer to construct a GUI with the following imports 1 /* 2 Generated by Entice Designer 3 Entice Designer written by Christopher E. Miller 4 www.dprogramming.com/entice.php 5 */ 6 7 import dwt.DWT; 8 import dwt.widgets.Display, dwt.widgets.Shell; 9 import dwt.widgets.Group, dwt.widgets.Text; 10 import dwt.widgets.Label, dwt.widgets.Combo; 11 import dwt.graphics.Color, dwt.graphics.Rectangle; 12 import dwt.widgets.MessageBox; 13 14 15 class MyShell 16 { 17 // Do not modify or move this block of variables. 18 //~Entice Designer variables begin here. 19 dwt.widgets.Shell.Shell shell; 20 dwt.widgets.Group.Group group1; 21 dwt.widgets.Text.Text text3; 22 dwt.widgets.Label.Label label5; 23 dwt.widgets.Text.Text Date; 24 dwt.widgets.Combo.Combo Payee; 25 dwt.widgets.Text.Text Code; 26 dwt.widgets.Text.Text ChequeNo; 27 dwt.widgets.Text.Text Details; 28 dwt.widgets.Button.Button OKButton; 29 dwt.widgets.Text.Text Credit; 30 dwt.widgets.Text.Text Debit; 31 dwt.widgets.Table.Table DataTable; 32 //~Entice Designer variables end here. Now he tells me that this compiles in windows as is . Notice he uses a Table . When I take the same program and compile it on Linux I must add " Import dwt.widgets.Table" or it will not compile. Now I am wondering if your problem with d l l ' s is similar ? Some built in assumptions that Linux does not have .
Apr 12 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Tower Ty wrote:
 Bill Baxter Wrote:
 
 Unknown W. Brackets wrote:

I'm interested here in understanding another difference between Linux and Windows. Chris Miller used Entice Designer to construct a GUI with the following imports 1 /* 2 Generated by Entice Designer 3 Entice Designer written by Christopher E. Miller 4 www.dprogramming.com/entice.php 5 */ 6 7 import dwt.DWT; 8 import dwt.widgets.Display, dwt.widgets.Shell; 9 import dwt.widgets.Group, dwt.widgets.Text; 10 import dwt.widgets.Label, dwt.widgets.Combo; 11 import dwt.graphics.Color, dwt.graphics.Rectangle; 12 import dwt.widgets.MessageBox; 13 14 15 class MyShell 16 { 17 // Do not modify or move this block of variables. 18 //~Entice Designer variables begin here. 19 dwt.widgets.Shell.Shell shell; 20 dwt.widgets.Group.Group group1; 21 dwt.widgets.Text.Text text3; 22 dwt.widgets.Label.Label label5; 23 dwt.widgets.Text.Text Date; 24 dwt.widgets.Combo.Combo Payee; 25 dwt.widgets.Text.Text Code; 26 dwt.widgets.Text.Text ChequeNo; 27 dwt.widgets.Text.Text Details; 28 dwt.widgets.Button.Button OKButton; 29 dwt.widgets.Text.Text Credit; 30 dwt.widgets.Text.Text Debit; 31 dwt.widgets.Table.Table DataTable; 32 //~Entice Designer variables end here. Now he tells me that this compiles in windows as is . Notice he uses a Table . When I take the same program and compile it on Linux I must add " Import dwt.widgets.Table" or it will not compile. Now I am wondering if your problem with d l l ' s is similar ? Some built in assumptions that Linux does not have .

I don't believe what Chris told you is true. I just used Entice designer to make a DWT gui on Windows yesterday, and it was missing many imports and wouldn't compile out of the box without adding them. --bb
Apr 12 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Bill Baxter wrote:
 Tower Ty wrote:
 Bill Baxter Wrote:

 Unknown W. Brackets wrote:

I'm interested here in understanding another difference between Linux and Windows. Chris Miller used Entice Designer to construct a GUI with the following imports 1 /* 2 Generated by Entice Designer 3 Entice Designer written by Christopher E. Miller 4 www.dprogramming.com/entice.php 5 */ 6 7 import dwt.DWT; 8 import dwt.widgets.Display, dwt.widgets.Shell; 9 import dwt.widgets.Group, dwt.widgets.Text; 10 import dwt.widgets.Label, dwt.widgets.Combo; 11 import dwt.graphics.Color, dwt.graphics.Rectangle; 12 import dwt.widgets.MessageBox; 13 14 15 class MyShell 16 { 17 // Do not modify or move this block of variables. 18 //~Entice Designer variables begin here. 19 dwt.widgets.Shell.Shell shell; 20 dwt.widgets.Group.Group group1; 21 dwt.widgets.Text.Text text3; 22 dwt.widgets.Label.Label label5; 23 dwt.widgets.Text.Text Date; 24 dwt.widgets.Combo.Combo Payee; 25 dwt.widgets.Text.Text Code; 26 dwt.widgets.Text.Text ChequeNo; 27 dwt.widgets.Text.Text Details; 28 dwt.widgets.Button.Button OKButton; 29 dwt.widgets.Text.Text Credit; 30 dwt.widgets.Text.Text Debit; 31 dwt.widgets.Table.Table DataTable; 32 //~Entice Designer variables end here. Now he tells me that this compiles in windows as is . Notice he uses a Table . When I take the same program and compile it on Linux I must add " Import dwt.widgets.Table" or it will not compile. Now I am wondering if your problem with d l l ' s is similar ? Some built in assumptions that Linux does not have .

I don't believe what Chris told you is true. I just used Entice designer to make a DWT gui on Windows yesterday, and it was missing many imports and wouldn't compile out of the box without adding them.

Well, ok, maybe "many" is a bit of an overstatement. But it did not compile out of the box without adding some additional imports. --bb
Apr 12 2008
prev sibling parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
Yes, I'd think it's Derelict's fault personally.  On Windows, 
LoadLibraryA is (as far as I know) in the same library as a bunch of 
other things you're going to need.

On Linux, it's separated into its own thing.  It's potentially possible 
you might want to write a Linux executable that does not require libdl, 
specifically for a system which might not have it.

That said, it seems fairly unlikely.  Surely you can change the dmd.conf 
file to automatically pass -L-ldl to dmd, solving your problem?

-[Unknown]


Bill Baxter wrote:
 Unknown W. Brackets wrote:
 Isn't this what the "lib" pragma is for, if you don't want to have to 
 pass it?

I suppose so (or "link" pragma using dsss/bud). So you're saying it could be considered "Derelict's fault" for not providing that pragma. On Windows, the equivalent libs (containing LoadLibraryA/FreeLibrary/GetProcAddress) seem to be linked by default, by someone in the toolchain. DMD or DSSS, I'm not sure which. So it seems reasonable that it should be there by default under Linux, too.
 -[Unknown]


 Bill Baxter wrote:
 Just wondering why I have to give dsss the -L-ldl flag manually when 
 I compile a Derelict-using program under Linux.

 Seems like it shouldn't be neecessary for me to have to specify that. 
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not 
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants 
 to use libdl on Linux?

 Any of those seem possible.  So anyone know the answer?

 Or is it just my fault for thinking I shouldn't have to stick a 
 version(linux) block in my dsss.conf file?

 --bb



Apr 12 2008
prev sibling next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
Bill Baxter wrote:

 Just wondering why I have to give dsss the -L-ldl flag manually when I
 compile a Derelict-using program under Linux.
 
 Seems like it shouldn't be neecessary for me to have to specify that.
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants to
 use libdl on Linux?
 
 Any of those seem possible.  So anyone know the answer?
 
 Or is it just my fault for thinking I shouldn't have to stick a
 version(linux) block in my dsss.conf file?
 
 --bb

It may be that it is derelict's fault for not working with the tools, but there is also the relevant bugzilla entries http://d.puremagic.com/issues/show_bug.cgi?id=1663 and http://d.puremagic.com/issues/show_bug.cgi?id=1690 pragma(lib) should be implemented on all platforms, or removed from the spec entirely. I'd certainly prefer the former, as this probably is the one thing that a build tool normally cannot do much beyond what the compiler already does by telling the linker about always needed libraries (like the runtime). -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
Apr 12 2008
next sibling parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
I had no idea.  I guess I should try to get my sneaker out of my mouth 
now...

I may see if I can find time to attach a patch in there (seems like 
something completely solvable using the frontend.)

-[Unknown]


Lars Ivar Igesund wrote:
 Bill Baxter wrote:
 
 Just wondering why I have to give dsss the -L-ldl flag manually when I
 compile a Derelict-using program under Linux.

 Seems like it shouldn't be neecessary for me to have to specify that.
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants to
 use libdl on Linux?

 Any of those seem possible.  So anyone know the answer?

 Or is it just my fault for thinking I shouldn't have to stick a
 version(linux) block in my dsss.conf file?

 --bb

It may be that it is derelict's fault for not working with the tools, but there is also the relevant bugzilla entries http://d.puremagic.com/issues/show_bug.cgi?id=1663 and http://d.puremagic.com/issues/show_bug.cgi?id=1690 pragma(lib) should be implemented on all platforms, or removed from the spec entirely. I'd certainly prefer the former, as this probably is the one thing that a build tool normally cannot do much beyond what the compiler already does by telling the linker about always needed libraries (like the runtime).

Apr 12 2008
prev sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Lars Ivar Igesund wrote:
 Bill Baxter wrote:
 
 Just wondering why I have to give dsss the -L-ldl flag manually when I
 compile a Derelict-using program under Linux.

 Seems like it shouldn't be neecessary for me to have to specify that.
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants to
 use libdl on Linux?

 Any of those seem possible.  So anyone know the answer?

 Or is it just my fault for thinking I shouldn't have to stick a
 version(linux) block in my dsss.conf file?

 --bb

It may be that it is derelict's fault for not working with the tools, but there is also the relevant bugzilla entries http://d.puremagic.com/issues/show_bug.cgi?id=1663 and http://d.puremagic.com/issues/show_bug.cgi?id=1690 pragma(lib) should be implemented on all platforms, or removed from the spec entirely.

That's certainly a problem. However, Derelict supports DSSS, so that's not really an excuse for Derelict. It could use DSSS's pragma(link). --bb
Apr 12 2008
parent reply Mike Parker <aldacron71 yahoo.com> writes:
Bill Baxter wrote:
 Lars Ivar Igesund wrote:

 It may be that it is derelict's fault for not working with the tools, but
 there is also the relevant bugzilla entries
 http://d.puremagic.com/issues/show_bug.cgi?id=1663

 and

 http://d.puremagic.com/issues/show_bug.cgi?id=1690

 pragma(lib) should be implemented on all platforms, or removed from 
 the spec
 entirely. 

That's certainly a problem. However, Derelict supports DSSS, so that's not really an excuse for Derelict. It could use DSSS's pragma(link). --bb

How is that going to help with the final executable? No linking is done during the compilation of static libraries, so even if I did add that to Derelict's dsss.conf files, the user would still have to link to libdl when compiling the executable.
Apr 12 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Mike Parker wrote:
 Bill Baxter wrote:
 Lars Ivar Igesund wrote:

 It may be that it is derelict's fault for not working with the tools, 
 but
 there is also the relevant bugzilla entries
 http://d.puremagic.com/issues/show_bug.cgi?id=1663

 and

 http://d.puremagic.com/issues/show_bug.cgi?id=1690

 pragma(lib) should be implemented on all platforms, or removed from 
 the spec
 entirely. 

That's certainly a problem. However, Derelict supports DSSS, so that's not really an excuse for Derelict. It could use DSSS's pragma(link). --bb

How is that going to help with the final executable? No linking is done during the compilation of static libraries, so even if I did add that to Derelict's dsss.conf files, the user would still have to link to libdl when compiling the executable.

You wouldn't put it in Derelict's dsss.conf, you'd put it in derelict/util/loader.d. And it would end up in the .di file, where it would be found by dsss later when users are trying to compile something that uses loader. --bb
Apr 12 2008
parent reply Mike Parker <aldacron71 yahoo.com> writes:
Bill Baxter wrote:
 Mike Parker wrote:
 Bill Baxter wrote:
 Lars Ivar Igesund wrote:

 It may be that it is derelict's fault for not working with the 
 tools, but
 there is also the relevant bugzilla entries
 http://d.puremagic.com/issues/show_bug.cgi?id=1663

 and

 http://d.puremagic.com/issues/show_bug.cgi?id=1690

 pragma(lib) should be implemented on all platforms, or removed from 
 the spec
 entirely. 

That's certainly a problem. However, Derelict supports DSSS, so that's not really an excuse for Derelict. It could use DSSS's pragma(link). --bb

How is that going to help with the final executable? No linking is done during the compilation of static libraries, so even if I did add that to Derelict's dsss.conf files, the user would still have to link to libdl when compiling the executable.

You wouldn't put it in Derelict's dsss.conf, you'd put it in derelict/util/loader.d. And it would end up in the .di file, where it would be found by dsss later when users are trying to compile something that uses loader.

I see now. I've updated the Derelict trunk with the pragma link.
Apr 13 2008
parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
Mike Parker wrote:

 Bill Baxter wrote:
 Mike Parker wrote:
 Bill Baxter wrote:
 Lars Ivar Igesund wrote:

 It may be that it is derelict's fault for not working with the
 tools, but
 there is also the relevant bugzilla entries
 http://d.puremagic.com/issues/show_bug.cgi?id=1663

 and

 http://d.puremagic.com/issues/show_bug.cgi?id=1690

 pragma(lib) should be implemented on all platforms, or removed from
 the spec
 entirely.

That's certainly a problem. However, Derelict supports DSSS, so that's not really an excuse for Derelict. It could use DSSS's pragma(link). --bb

How is that going to help with the final executable? No linking is done during the compilation of static libraries, so even if I did add that to Derelict's dsss.conf files, the user would still have to link to libdl when compiling the executable.

You wouldn't put it in Derelict's dsss.conf, you'd put it in derelict/util/loader.d. And it would end up in the .di file, where it would be found by dsss later when users are trying to compile something that uses loader.

I see now. I've updated the Derelict trunk with the pragma link.

For reference, this is where I think that pragma lib should be available from the compiler instead, such that the correct lib will be linked even with a different build tool. -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
Apr 13 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Lars Ivar Igesund wrote:
 Mike Parker wrote:
 
 Bill Baxter wrote:
 Mike Parker wrote:
 Bill Baxter wrote:
 Lars Ivar Igesund wrote:
 It may be that it is derelict's fault for not working with the
 tools, but
 there is also the relevant bugzilla entries
 http://d.puremagic.com/issues/show_bug.cgi?id=1663

 and

 http://d.puremagic.com/issues/show_bug.cgi?id=1690

 pragma(lib) should be implemented on all platforms, or removed from
 the spec
 entirely.

However, Derelict supports DSSS, so that's not really an excuse for Derelict. It could use DSSS's pragma(link). --bb

done during the compilation of static libraries, so even if I did add that to Derelict's dsss.conf files, the user would still have to link to libdl when compiling the executable.

derelict/util/loader.d. And it would end up in the .di file, where it would be found by dsss later when users are trying to compile something that uses loader.


For reference, this is where I think that pragma lib should be available from the compiler instead, such that the correct lib will be linked even with a different build tool.

Agreed. I think it's yet another one of those things that has been debated, hailed by all, then ignored, then forgotten. But DSSS takes the feature from Bud, I believe. So if all D-aware build tools implement it, then it's not so bad. Of course that doesn't help 'make' users. Incidentially, this may be a good time to once again bring up Gregor's proposal of dmd -v spitting out pragmas in addition to imports. It would make supporting things like pragma("link") much easier for any build tool that wanted to. --bb
Apr 13 2008
prev sibling parent reply Spacen Jasset <spacenjasset yahoo.co.uk> writes:
Bill Baxter wrote:
 Just wondering why I have to give dsss the -L-ldl flag manually when I 
 compile a Derelict-using program under Linux.
 
 Seems like it shouldn't be neecessary for me to have to specify that. 
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not 
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants to 
 use libdl on Linux?
 
 Any of those seem possible.  So anyone know the answer?
 
 Or is it just my fault for thinking I shouldn't have to stick a 
 version(linux) block in my dsss.conf file?
 
 --bb

It's sort of the Linux way I guess. You have to do this using C++ to use any of the dynamic binding functions. A dsss link pragma seems to be the solution for the moment. Or, you can list lib 'dl' in your dsss.conf and you will get a warning on windows but it will still link correctly. buildflags=-g -lldl -debug -unittest -Dddocs -profile OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. dl.lib Warning 2: File Not Found dl.lib
Apr 14 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Spacen Jasset wrote:
 Bill Baxter wrote:
 Just wondering why I have to give dsss the -L-ldl flag manually when I 
 compile a Derelict-using program under Linux.

 Seems like it shouldn't be neecessary for me to have to specify that. 
 But who's to blame?
 * Is it DMD's fault for not including in the default link libs?
 * Is it DSSS's fault for not picking up that it's needed (or for not 
 puttin it in the default list of flags?)
 * Is it Derelict's fault for somehow not telling DSSS that it wants to 
 use libdl on Linux?

 Any of those seem possible.  So anyone know the answer?

 Or is it just my fault for thinking I shouldn't have to stick a 
 version(linux) block in my dsss.conf file?

 --bb

It's sort of the Linux way I guess. You have to do this using C++ to use any of the dynamic binding functions. A dsss link pragma seems to be the solution for the moment. Or, you can list lib 'dl' in your dsss.conf and you will get a warning on windows but it will still link correctly. buildflags=-g -lldl -debug -unittest -Dddocs -profile OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. dl.lib Warning 2: File Not Found dl.lib

Mike/Aldacron added the link pragma to Derelict's svn yesterday. So at least with DSSS (and bud I think) the -L-ldl is no longer needed for building programs with Derelict. --bb
Apr 14 2008