www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DMD -L Flag, maybe a bug?

reply Bubbasaur <bubba gmail.com> writes:
If you follow the link below:

https://dlang.org/dmd-windows.html#switch-L

It's written:

"
    -Llinkerflag

    pass linkerflag to the linker link.exe , for example, -L/ma/li
"

But at least on Windows, you need to put a space between -L and 
the PATH. Which It's weird, since with "-I" flag you don't need 
any space.

It took me 30 minutes until I find why my program wasn't 
compiling. (I found the tip on a forum elsewhere).

Is this a bug or a mistake?

Bubba.
Dec 25 2015
parent reply anonymous <anonymous example.com> writes:
On 25.12.2015 15:40, Bubbasaur wrote:
 But at least on Windows, you need to put a space between -L and the
 PATH. Which It's weird, since with "-I" flag you don't need any space.
I don't think that's right. Unless something awful is going in Windows dmd, that should be processed as two separate entities: "-L" passes nothing to the linker, and whatever you try to send the linker is interpreted independently by dmd. You can try removing the "-L" entirely. If it still works, then dmd is apparently able to handle things for you, and you don't need to go the linker yourself. What exactly are trying to pass to the linker?
 It took me 30 minutes until I find why my program wasn't compiling. (I
 found the tip on a forum elsewhere).
Can you give a link to that?
Dec 25 2015
parent reply Bubbasaur <bubba gmail.com> writes:
On Friday, 25 December 2015 at 15:06:27 UTC, anonymous wrote:
 ...
 You can try removing the "-L" entirely. If it still works...
In fact it works without the "-L". Which makes me wonder if I was using it wrongly?
 What exactly are trying to pass to the linker?
A lib: GtkD.
 Can you give a link to that?
Sure (It's the second from the last answer): http://www.dsource.org/forums/viewtopic.php?t=4928&sid=e1caca2e12a14c49672a92126dc0922c Bubba.
Dec 25 2015
parent reply anonymous <anonymous example.com> writes:
On 25.12.2015 19:32, Bubbasaur wrote:
 On Friday, 25 December 2015 at 15:06:27 UTC, anonymous wrote:
 In fact it works without the "-L". Which makes me wonder if I was using
 it wrongly?
I'm convinced that putting a space between "-L" and its argument is nonsense. The "-L" part just means "pass the empty string to the linker", which doesn't do anything. And the argument is interpreted by dmd then, not by the linker.
 What exactly are trying to pass to the linker?
A lib: GtkD.
That means a .lib file, right? dmd knows how to handle .lib files [1], so it's no surprise that things work when you pass the .lib file to dmd. The GtkD docs say to use -L though [2], so I suppose that should work too. Maybe show your exact complete command line, if you want to find out why it doesn't work for you. [1] http://dlang.org/dmd-windows.html#switches [2] https://github.com/gtkd-developers/GtkD/wiki/Installing-on-Windows#testing-installation
Dec 25 2015
parent reply Bubbasaur <bubba gmail.com> writes:
On Friday, 25 December 2015 at 23:45:42 UTC, anonymous wrote:
 ...
 That means a .lib file, right?
Yes.
 The GtkD docs say to use -L though [2], so I suppose that 
 should work too.
 Maybe show your exact complete command line, if you want to 
 find out why it doesn't work for you.
It's almost like the example in the URL you showed: dmd test.d -LC:/gtkd/src/build/GtkD.lib Where the command above doesn't works, on the other hand the 2 others below works: dmd test.d -L C:/gtkd/src/build/GtkD.lib dmd test.d C:/gtkd/src/build/GtkD.lib But if you do a search for problems like: Linking problem or Symbol Undefined most command lines uses this: "-Lpath/to/whatever" (Without Space). And another thing... there is other flag commonly used "-I" with doesn't need space, so most people will assume the same for -L. Well this problem took only 30 minutes, because luckily I found the answer on the second link, but it could take hours. Bubba.
Dec 25 2015
next sibling parent reply anonymous <anonymous example.com> writes:
On 26.12.2015 02:04, Bubbasaur wrote:
 On Friday, 25 December 2015 at 23:45:42 UTC, anonymous wrote:
 It's almost like the example in the URL you showed:

 dmd test.d -LC:/gtkd/src/build/GtkD.lib
Note that in the docs I linked it's `dmd hello.d -L+gtkd.lib` with a plus sign. I'm not sure if it's significant, but it's a difference. Also, and this may be it, the link.exe that's distributed with dmd doesn't like forward slashes as path separators. You can try it with backslashes instead: dmd test.d -LC:\gtkd\src\build\GtkD.lib
 But if you do a search for problems like: Linking problem or Symbol
 Undefined most command lines uses this: "-Lpath/to/whatever" (Without
 Space). And another thing... there is other flag commonly used "-I" with
 doesn't need space, so most people will assume the same for -L.
-L doesn't take a space, either. Putting a space there isn't even optional, it's wrong. The stuff after the space is not passed to the linker, it's interpreted by dmd.
Dec 26 2015
parent Bubbasaur <bubba gmail.com> writes:
On Saturday, 26 December 2015 at 11:19:27 UTC, anonymous wrote:
 ...
 Note that in the docs I linked it's `dmd hello.d -L+gtkd.lib` 
 with a plus sign. I'm not sure if it's significant, but it's a 
 difference.
There are two ways in the doc you linked: dmd hello.d -L+gtkd.lib or dmd hello.d -Lgtkd.lib -m64 The second doesn't uses "+" but it has "-m64". Anyway even the example with "+" it doesn't working here either.
 Also, and this may be it, the link.exe that's distributed with 
 dmd doesn't like forward slashes as path separators. You can 
 try it with backslashes instead:

 dmd test.d -LC:\gtkd\src\build\GtkD.lib
I had tried that before, without any success.
 -L doesn't take a space, either. Putting a space there isn't 
 even optional, it's wrong. The stuff after the space is not 
 passed to the linker, it's interpreted by dmd.
In fact I already had understood what happened after your first answer, which "-L" with space wasn't been "evaluated" because DMD was reading a flag without arguments. So I could omit it there, but like I said, many examples out there uses: "-Lpath/to/whatever", and then you see many topics about people complaining about this. Bubba.
Dec 26 2015
prev sibling parent reply Ivan Kazmenko <gassa mail.ru> writes:
On Saturday, 26 December 2015 at 01:04:57 UTC, Bubbasaur wrote:
 It's almost like the example in the URL you showed:

 dmd test.d -LC:/gtkd/src/build/GtkD.lib
Note that -L passes flags (options) but not necessarily arguments or paths. For example, I use "dmd -L/STACK:268435456" by default along with other options to increase the default stack size to 256Mb. The "/STACK:268435456" part is an OPTLINK switch, not a path. Here is the list of OPTLINK switches: http://www.digitalmars.com/ctg/ctgLinkSwitches.html Clearly, the forward slash (/) is reserved for switches, so the program will have trouble parsing paths with forward slashes.
Dec 26 2015
parent Bubbasaur <bubba gmail.com> writes:
On Saturday, 26 December 2015 at 11:53:55 UTC, Ivan Kazmenko 
wrote:
 Note that -L passes flags (options) but not necessarily 
 arguments or paths.  For example, I use "dmd 
 -L/STACK:268435456" by default along with other options to 
 increase the default stack size to 256Mb.
Your comment is reasonable enough, but unfortunately the main problem is there are examples on the internet using this "-L" for this kind of thing. If go here: http://wiki.dlang.org/Compiling_and_linking_with_DMD_on_Windows#Static_Libraries_and_Import_Paths There is an example in: "Passing search directories for static library files to Optlink", which follows: C:\Project\main.d C:\Project\lib\mylib.lib where main.d depends on the mylib library, you can compile via: dmd -L+.\lib\ driver.d mylib.lib Yes there is a "+" plus sign and a "." dot there, but I believe people gets confuse and uses it as "-I".
 Clearly, the forward slash (/) is reserved for switches, so the 
 program will have trouble parsing paths with forward slashes.
About this in fact this was my mistake, because originally I had tried "\" and since it wasn't working so I change to "/" and that remains. Bubba.
Dec 26 2015