View mode: basic / threaded / horizontal-split · Log in · Help
September 29, 2011
Simple I know, but could use some help compiling with make
It's my first foray into the arcana of makefiles and command line compiling.

My makefile looks like this:

IMPORT = -IC:\Dlang\dmd2\src\ext\Derelict2\import
LIB_PATHS = -LC:\Dlang\dmd2\src\ext\Derelict2\lib
LIB_INCLUDES = DerelictSDL.lib DerelictGL.lib DerelictUtil.lib

all:
	dmd src/main.d src/display.d src/renderdata.d src/vector2d.d\
	$(IMPORT) $(LIB_PATHS) $(LIB_INCLUDES)

I think I just don't know how to give the compiler what it wants. I can 
build it manually by simply including the full paths to each of those 
libraries, but I'd rather avoid having to do that unless necessary. Is 
there something I'm just missing?
September 29, 2011
Re: Simple I know, but could use some help compiling with make
On Thu, 29 Sep 2011 14:23:41 -0400, Roderick Gibson <kniteli@gmail.com>  
wrote:

> It's my first foray into the arcana of makefiles and command line  
> compiling.
>
> My makefile looks like this:
>
> IMPORT = -IC:\Dlang\dmd2\src\ext\Derelict2\import
> LIB_PATHS = -LC:\Dlang\dmd2\src\ext\Derelict2\lib
> LIB_INCLUDES = DerelictSDL.lib DerelictGL.lib DerelictUtil.lib
>
> all:
> 	dmd src/main.d src/display.d src/renderdata.d src/vector2d.d\
> 	$(IMPORT) $(LIB_PATHS) $(LIB_INCLUDES)
>
> I think I just don't know how to give the compiler what it wants. I can  
> build it manually by simply including the full paths to each of those  
> libraries, but I'd rather avoid having to do that unless necessary. Is  
> there something I'm just missing?

Library options start with -L.  dmd passes everything after the -L to the  
linker.

What you need to do (I am making a vague guess that you are on windows :)   
is look up OPTLINK's command line options, then use those options after -L.

As one who does not do much on Windows, I can tell you that it's very odd  
when doing dmd commands on Linux, for example:

dmd myfile.d -L-Lpath/to/libs -L-lmylib

Note the extra -L prefixes are needed, the same is for Windows.

-Steve
September 29, 2011
Re: Simple I know, but could use some help compiling with make
No it's not the same for Windows. On Windows you have to use -L+, e.g.:

dmd myfile.d -L+path/to/libs mylib.lib
September 29, 2011
Re: Simple I know, but could use some help compiling with make
Documented here:
http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/CompilingLinkingD#PassingsearchdirectoriesforstaticlibraryfilestoOptlink

Damn what a big hashtag, lol.
September 29, 2011
Re: Simple I know, but could use some help compiling with make
On Thu, 29 Sep 2011 14:32:28 -0400, Andrej Mitrovic  
<andrej.mitrovich@gmail.com> wrote:

> No it's not the same for Windows. On Windows you have to use -L+, e.g.:
>
> dmd myfile.d -L+path/to/libs mylib.lib

That's because +path/to/libs is the search-path parameter for OPTLINK.  -L  
goes before all linker parameters.  The same is for Linux.

See here: http://www.digitalmars.com/d/2.0/dmd-windows.html

-Steve
September 29, 2011
Re: Simple I know, but could use some help compiling with make
On 9/29/11, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
> On Thu, 29 Sep 2011 14:32:28 -0400, Andrej Mitrovic
> <andrej.mitrovich@gmail.com> wrote:
>
>> No it's not the same for Windows. On Windows you have to use -L+, e.g.:
>>
>> dmd myfile.d -L+path/to/libs mylib.lib
>
> That's because +path/to/libs is the search-path parameter for OPTLINK.  -L
> goes before all linker parameters.  The same is for Linux.
>
> See here: http://www.digitalmars.com/d/2.0/dmd-windows.html
>
> -Steve
>

Right, I misinterpreted the "same for Windows" part, you were
referring to -L and you're right.

DMD could do some magic and replace -L-L with -L+ on Windows to
simplify cross-platform development. I know it sends everything after
-L to the linker, but it could make one special case for this.
September 29, 2011
Re: Simple I know, but could use some help compiling with make
On 9/29/2011 11:52 AM, Andrej Mitrovic wrote:
> On 9/29/11, Steven Schveighoffer<schveiguy@yahoo.com>  wrote:
>> On Thu, 29 Sep 2011 14:32:28 -0400, Andrej Mitrovic
>> <andrej.mitrovich@gmail.com>  wrote:
>>
>>> No it's not the same for Windows. On Windows you have to use -L+, e.g.:
>>>
>>> dmd myfile.d -L+path/to/libs mylib.lib
>>
>> That's because +path/to/libs is the search-path parameter for OPTLINK.  -L
>> goes before all linker parameters.  The same is for Linux.
>>
>> See here: http://www.digitalmars.com/d/2.0/dmd-windows.html
>>
>> -Steve
>>
>
> Right, I misinterpreted the "same for Windows" part, you were
> referring to -L and you're right.
>
> DMD could do some magic and replace -L-L with -L+ on Windows to
> simplify cross-platform development. I know it sends everything after
> -L to the linker, but it could make one special case for this.


Thanks so much guys, it worked, although it looks like a mutated 
wildebeest.  For the interested:

IMPORT = -IC:\Dlang\dmd2\src\ext\Derelict2\import
LIB_PATHS = -L+C:\Dlang\dmd2\src\ext\Derelict2\lib\\

LIB_INCLUDES = DerelictSDL.lib DerelictGL.lib DerelictUtil.lib 
DerelictGLU.lib

all:
	dmd src/main.d src/display.d src/renderdata.d src/vector2d.d $(IMPORT) 
$(LIB_PATHS) $(LIB_INCLUDES)

Yes, that is TWO backslashes and the empty line between paths and 
includes is required. Could probably fix it but couldn't figure out how 
to escape the backslash (to prevent it from escaping the newline).
September 29, 2011
Re: Simple I know, but could use some help compiling with make
On Thu, 29 Sep 2011 15:28:56 -0400, Roderick Gibson <kniteli@gmail.com>  
wrote:

> On 9/29/2011 11:52 AM, Andrej Mitrovic wrote:
>> On 9/29/11, Steven Schveighoffer<schveiguy@yahoo.com>  wrote:
>>> On Thu, 29 Sep 2011 14:32:28 -0400, Andrej Mitrovic
>>> <andrej.mitrovich@gmail.com>  wrote:
>>>
>>>> No it's not the same for Windows. On Windows you have to use -L+,  
>>>> e.g.:
>>>>
>>>> dmd myfile.d -L+path/to/libs mylib.lib
>>>
>>> That's because +path/to/libs is the search-path parameter for  
>>> OPTLINK.  -L
>>> goes before all linker parameters.  The same is for Linux.
>>>
>>> See here: http://www.digitalmars.com/d/2.0/dmd-windows.html
>>>
>>> -Steve
>>>
>>
>> Right, I misinterpreted the "same for Windows" part, you were
>> referring to -L and you're right.
>>
>> DMD could do some magic and replace -L-L with -L+ on Windows to
>> simplify cross-platform development. I know it sends everything after
>> -L to the linker, but it could make one special case for this.
>
>
> Thanks so much guys, it worked, although it looks like a mutated  
> wildebeest.  For the interested:
>
> IMPORT = -IC:\Dlang\dmd2\src\ext\Derelict2\import
> LIB_PATHS = -L+C:\Dlang\dmd2\src\ext\Derelict2\lib\\
>
> LIB_INCLUDES = DerelictSDL.lib DerelictGL.lib DerelictUtil.lib  
> DerelictGLU.lib
>
> all:
> 	dmd src/main.d src/display.d src/renderdata.d src/vector2d.d $(IMPORT)  
> $(LIB_PATHS) $(LIB_INCLUDES)
>
> Yes, that is TWO backslashes and the empty line between paths and  
> includes is required. Could probably fix it but couldn't figure out how  
> to escape the backslash (to prevent it from escaping the newline).

Can you just leave off the last backslash?  Again, not too familiar with  
OPTLINK, so not sure.

-Steve
September 29, 2011
Re: Simple I know, but could use some help compiling with make
On 9/29/2011 1:02 PM, Steven Schveighoffer wrote:
> On Thu, 29 Sep 2011 15:28:56 -0400, Roderick Gibson <kniteli@gmail.com>
> wrote:
>
>> On 9/29/2011 11:52 AM, Andrej Mitrovic wrote:
>>> On 9/29/11, Steven Schveighoffer<schveiguy@yahoo.com> wrote:
>>>> On Thu, 29 Sep 2011 14:32:28 -0400, Andrej Mitrovic
>>>> <andrej.mitrovich@gmail.com> wrote:
>>>>
>>>>> No it's not the same for Windows. On Windows you have to use -L+,
>>>>> e.g.:
>>>>>
>>>>> dmd myfile.d -L+path/to/libs mylib.lib
>>>>
>>>> That's because +path/to/libs is the search-path parameter for
>>>> OPTLINK. -L
>>>> goes before all linker parameters. The same is for Linux.
>>>>
>>>> See here: http://www.digitalmars.com/d/2.0/dmd-windows.html
>>>>
>>>> -Steve
>>>>
>>>
>>> Right, I misinterpreted the "same for Windows" part, you were
>>> referring to -L and you're right.
>>>
>>> DMD could do some magic and replace -L-L with -L+ on Windows to
>>> simplify cross-platform development. I know it sends everything after
>>> -L to the linker, but it could make one special case for this.
>>
>>
>> Thanks so much guys, it worked, although it looks like a mutated
>> wildebeest. For the interested:
>>
>> IMPORT = -IC:\Dlang\dmd2\src\ext\Derelict2\import
>> LIB_PATHS = -L+C:\Dlang\dmd2\src\ext\Derelict2\lib\\
>>
>> LIB_INCLUDES = DerelictSDL.lib DerelictGL.lib DerelictUtil.lib
>> DerelictGLU.lib
>>
>> all:
>> dmd src/main.d src/display.d src/renderdata.d src/vector2d.d $(IMPORT)
>> $(LIB_PATHS) $(LIB_INCLUDES)
>>
>> Yes, that is TWO backslashes and the empty line between paths and
>> includes is required. Could probably fix it but couldn't figure out
>> how to escape the backslash (to prevent it from escaping the newline).
>
> Can you just leave off the last backslash? Again, not too familiar with
> OPTLINK, so not sure.
>
> -Steve

Nope, because then the first backslash would be escaping the newline and 
the linker looks for Derelict2\lib.lib instead of Derelict2\lib\.
September 29, 2011
Re: Simple I know, but could use some help compiling with make
Odd, I never have to do double backslashes. Maybe it's a problem with
make. Personally I just use batch files, I kind of got used to them
for simple projects. For everything else a D script is my handy tool.
« First   ‹ Prev
1 2 3
Top | Discussion index | About this forum | D home