Simple I know, but could use some help compiling with make

Nick Sabalausky a at a.a
Thu Sep 29 14:39:04 PDT 2011


"Roderick Gibson" <kniteli at gmail.com> wrote in message 
news:j62nvo$2237$1 at digitalmars.com...
> On 9/29/2011 2:15 PM, Nick Sabalausky wrote:
>> "Nick Sabalausky"<a at a.a>  wrote in message
>> news:j62msu$205t$1 at digitalmars.com...
>>> "Roderick Gibson"<kniteli at gmail.com>  wrote in message
>>> news:j62d4i$1d8l$1 at digitalmars.com...
>>>> 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?
>>>
>>> build.bat:
>>> @echo off
>>> rdmd --build-only -ofmyApp -IC:\Dlang\dmd2\src\ext\Derelict2\import -L+C:\Dlang\dmd2\src\ext\Derelict2\lib\
>>> DerelictSDL.lib DerelictGL.lib DerelictUtil.lib DerelictGLU.lib 
>>> src/main.d
>>>
>>> Note:
>>>
>>> 1. After the "@echo off", that's supposed to be one line.
>>>
>>> 2. "rdmd" instead of "dmd"
>>>
>>> 3. Only one ".d" file is given: The one with main()
>>>
>>> 4. The ".d" file is the *last* param.
>>>
>>
>> Or to make it a little cleaner:
>>
>> @echo off
>>
>> 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
>> EXE_NAME = myApp
>>
>> rdmd --build-only -of%EXE_NAME% %IMPORT% %LIB_PATHS% %LIB_INCLUDES%
>> src/main.d
>>
>> Of course, you can use rdmd with make too, but I've never really liked
>> dealing with make.
>>
>>
>
> Very cool, thanks for going to all the trouble. It only takes the one 
> souce file, does rdmd build out other files automatically?

What rdmd does is takes the file with "main()", figures out all the ".d" 
files needed, checks if any of them have been changed, and if so, it sends 
them all to dmd to be compiled. If you omit the "--build-only" it will also 
run the program you built. The full format for rdmd is:

rdmd {params for dmd and rdmd} main.d {params for main.exe}

So if you have:

//main.d
import std.stdio;
void main(string[] args)
{
    writeln("Hello", args[1]);
}

Then you can do this:

> rdmd main.d Joe
Hello Joe

>

It's an awesome tool. You can run just "rdmd" by itself to see all it's 
options.

Be aware though, rdmd has some issues if you're not using at least DMD 
2.055.





More information about the Digitalmars-d-learn mailing list