Compiling D through command line

Bauss streetzproductionz at hotmail.com
Fri Mar 7 09:50:09 PST 2014


On Friday, 7 March 2014 at 17:44:46 UTC, H. S. Teoh wrote:
> 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

Alright ty, but since you only specify the module names, how 
would it know to look in which path? Also do I have to specify 
all the modules from the std lib etc.?


More information about the Digitalmars-d-learn mailing list