2013-02-18 29 views
0

我是使用命令行編譯代碼的新手,所以我想知道如何使D編譯器將其所有代碼編譯到某個位置,而不是源代碼的位置。正如我希望最終的.exe和obj代碼都在特定的目錄中一樣。我知道你可以使用-of命令,但我目前不知道使用它的格式。 目前我有:如何編譯到不同的位置

C:\D\dmd2\windows\bin\dmd.exe -w C:\Users\Kyle\Desktop\D\Test.d C:\Users\Kyle\Desktop\D\src\MyMod.d 

我需要添加什麼?

回答

2

使用-offilename開關。例如:

dmd factorial.d -offilename "d:\test_name.exe" 

或短版:

dmd factorial.d "-ofd:\test_name.exe" 

注:雙引號是必要的,如果你的路徑包含空格。注2:短版本可以跳過.exe,但不要在完整版本中完成,因爲編譯器會搜索具有該名稱的源文件。

+3

我以爲是'dmd factorial.d「-ofd:\ test_name.exe」' – 2013-02-18 16:39:04

+0

@ratchetfreak這個也可以。 – sigod 2013-02-18 17:08:04

+1

我敢打賭,這是因爲它不清楚什麼是開關,從DMD的幫助,所以他們讓-of和--offilename :) – DejanLekic 2013-02-19 08:47:25

0

看看-of,-od-op開關。通過「將所有代碼編譯到某個位置」,不知道你的意思是什麼就很難具體。

1

我知道人們不喜歡RTFM答案,但下面是那種RTFM回答,回答你的問題:

執行dmd --help,你會得到如下:

DMD32 D Compiler v2.061 
Copyright (c) 1999-2012 by Digital Mars written by Walter Bright 
Documentation: http://www.dlang.org/index.html 
Usage: 
    dmd files.d ... { -switch } 

    files.d  D source files 
    @cmdfile  read arguments from cmdfile 
    -c    do not link 
    -cov   do code coverage analysis 
    -D    generate documentation 
    -Dddocdir  write documentation file to docdir directory 
    -Dffilename write documentation file to filename 
    -d    silently allow deprecated features 
    -dw   show use of deprecated features as warnings (default) 
    -de   show use of deprecated features as errors (halt compilation) 
    -debug   compile in debug code 
    -debug=level compile in debug code <= level 
    -debug=ident compile in debug code identified by ident 
    -debuglib=name set symbolic debug library to name 
    -defaultlib=name set default library to name 
    -deps=filename write module dependencies to filename 
    -g    add symbolic debug info 
    -gc   add symbolic debug info, pretend to be C 
    -gs   always emit stack frame 
    -H    generate 'header' file 
    -Hddirectory write 'header' file to directory 
    -Hffilename write 'header' file to filename 
    --help   print help 
    -Ipath   where to look for imports 
    -ignore  ignore unsupported pragmas 
    -inline  do function inlining 
    -Jpath   where to look for string imports 
    -Llinkerflag pass linkerflag to link 
    -lib   generate library rather than object files 
    -man   open web browser on manual page 
    -map   generate linker .map file 
    -noboundscheck turns off array bounds checking for all functions 
    -O    optimize 
    -o-   do not write object file 
    -odobjdir  write object & library files to directory objdir 
    -offilename name output file to filename  <---- [1] 
    -op   do not strip paths from source file 
    -profile  profile runtime performance of generated code 
    -property  enforce property syntax 
    -quiet   suppress unnecessary messages 
    -release  compile release version 
    -run srcfile args... run resulting program, passing args 
    -unittest  compile in unit tests 
    -v    verbose 
    -version=level compile in version code >= level 
    -version=ident compile in version code identified by ident 
    -vtls   list all variables going into thread local storage 
    -w    warnings as errors (compilation will halt) 
    -wi   warnings as messages (compilation will continue) 
    -X    generate JSON file 
    -Xffilename write JSON file to filename 

我標誌着線,回答你的問題與[1]和一個箭頭。

相關問題