September 29, 2011
"Roderick Gibson" <kniteli@gmail.com> wrote in message news:j62d4i$1d8l$1@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.


September 29, 2011
"Nick Sabalausky" <a@a.a> wrote in message news:j62msu$205t$1@digitalmars.com...
> "Roderick Gibson" <kniteli@gmail.com> wrote in message news:j62d4i$1d8l$1@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.


September 29, 2011
On Thu, 29 Sep 2011 16:30:54 -0400, Roderick Gibson <kniteli@gmail.com> wrote:

> 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\.

I mean, leave off the, um... first last backslash too :)

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

-Steve
September 29, 2011
On 9/29/2011 2:15 PM, Nick Sabalausky wrote:
> "Nick Sabalausky"<a@a.a>  wrote in message
> news:j62msu$205t$1@digitalmars.com...
>> "Roderick Gibson"<kniteli@gmail.com>  wrote in message
>> news:j62d4i$1d8l$1@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?
September 29, 2011
On 9/29/2011 2:19 PM, Steven Schveighoffer wrote:
> On Thu, 29 Sep 2011 16:30:54 -0400, Roderick Gibson <kniteli@gmail.com>
> wrote:
>
>> 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\.
>
> I mean, leave off the, um... first last backslash too :)
>
> LIB_PATHS = -L+C:\Dlang\dmd2\src\ext\Derelict2\lib
>
> -Steve

In that case it starts looking for Derelict2\lib.lib instead of Derelict2\lib\
September 29, 2011
"Roderick Gibson" <kniteli@gmail.com> wrote in message news:j62nvo$2237$1@digitalmars.com...
> On 9/29/2011 2:15 PM, Nick Sabalausky wrote:
>> "Nick Sabalausky"<a@a.a>  wrote in message news:j62msu$205t$1@digitalmars.com...
>>> "Roderick Gibson"<kniteli@gmail.com>  wrote in message news:j62d4i$1d8l$1@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.



September 29, 2011
On 9/29/2011 2:39 PM, Nick Sabalausky wrote:
> "Roderick Gibson"<kniteli@gmail.com>  wrote in message
> news:j62nvo$2237$1@digitalmars.com...
>> On 9/29/2011 2:15 PM, Nick Sabalausky wrote:
>>> "Nick Sabalausky"<a@a.a>   wrote in message
>>> news:j62msu$205t$1@digitalmars.com...
>>>> "Roderick Gibson"<kniteli@gmail.com>   wrote in message
>>>> news:j62d4i$1d8l$1@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.
>
>
>

Hmm, looks like it would be awesome, unfortunately it spits out a bunch of "previous definition different" errors on the linker, in relation to the libraries. Oh well, I seem to be able to get it working with dmd for now.
October 01, 2011
Roderick Gibson wrote:

...
> Hmm, looks like it would be awesome, unfortunately it spits out a bunch of "previous definition different" errors on the linker, in relation to the libraries. Oh well, I seem to be able to get it working with dmd for now.

This could be caused by having two 'main' functions in all the modules that rdmd finds.
October 05, 2011
I had exactly this problem too, I asked on the Derelict forums: http://www.dsource.org/forums/viewtopic.php?t=5856&sid=8ebff671fafec3bd8962ddfceaf99eb8

At the moment I've resolved this by building Derelict with make, first a normal full build, then a second run using the cleandi target, which removes the generated di files. I've set up the Derelict lib and include paths in dmd's sc.ini file, so I just have to call 'rdmd main.d' to build and run.
October 08, 2011
On 10/5/2011 7:46 AM, Ola Ost wrote:
> I had exactly this problem too, I asked on the Derelict forums:
> http://www.dsource.org/forums/viewtopic.php?t=5856&sid=8ebff671fafec3bd8962ddfceaf99eb8
>
> At the moment I've resolved this by building Derelict with make, first a normal full
> build, then a second run using the cleandi target, which removes the generated di files.
> I've set up the Derelict lib and include paths in dmd's sc.ini file, so I just have to
> call 'rdmd main.d' to build and run.

Hmm, so it's a bug in rdmd trying to compile the .di files or something?
1 2 3
Top | Discussion index | About this forum | D home