Compiling D through command line

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Mar 7 09:43:16 PST 2014


On Fri, Mar 07, 2014 at 04:59:29PM +0000, Bauss wrote:
> What arguments would I do to compile a d project through command
> line. Been trying a few things, but can't get it working.

I always use the command line, and it has always worked fine for me.
(Caveat: I use Linux, so I've no idea if what I say applies to Windows
in any way.) It's simply:

	dmd -ofprogram main.d module1.d module2.d ...

I assume on Windows it would be something like:

	dmd.exe -ofprogram.exe main.d module1.d module2.d ...

Note that you do have to specify all source files, including any sources
in subdirectories that your code uses, otherwise you may get linker
errors.


> I always get "Error: cannot read file x"
> 
> Read around the net and it most says it's an installation error and
> that reinstalling should fix it, but it works when compiling through
> a few IDE's so I assume it's mistake of my own.
> 
> Tried like this:
> -c c:\testproject\main.d -m32 -ofc:\testd\out.exe

Why are you using -c? That is only if you want to separately compile
individual source files into object files without linking. If you're
trying to make an executable, you shouldn't be using -c.


T

-- 
A program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes the potential for it to be applied to tasks that are
conceptually similar and, more important, to tasks that have not yet
been conceived. -- Michael B. Allen


More information about the Digitalmars-d-learn mailing list