如何更改 Nim 编译器输出文件的位置和名称
How to change Nim compiler output file location and name
使用 nim c -r example.nim
编译 Nim 程序会创建输出文件 example
。我想在另一个名为 bin/example.o
的文件夹中创建一个输出文件,这更容易被 gitignore.
到目前为止我尝试过的:
nim c -r example.nim -o:bin/example.o
nim c -r example.nim --out:bin/example.o
nim c -r example.nim -o:example.o
nim c -r example.nim --out:example.o
所有这些尝试的结果与我遗漏 -o/--out
选项的结果相同,导致在与 example.nim
文件相同的文件夹中生成可执行文件 example
.如果我不传入 -r
选项,编译器甚至不会接受该选项(这让我觉得我误解了该选项的用途)。
我正在使用从 github devel
分支源安装和编译的 Nim 0.10.3。
哪个编译器选项允许我修改编译后的输出文件?
你做的是对的,但选项必须在你正在编译的文件之前。您指定 -r
以在编译后执行文件,因此它将是 运行 并在文件后指定所有参数。
所以这应该有效:
nim c -o:bin/example -r example.nim
nim c -o=bin/example -r example.nim
nim c --out:bin/example -r example.nim
nim c --out=bin/example -r example.nim
使用 nim c -r example.nim
编译 Nim 程序会创建输出文件 example
。我想在另一个名为 bin/example.o
的文件夹中创建一个输出文件,这更容易被 gitignore.
到目前为止我尝试过的:
nim c -r example.nim -o:bin/example.o
nim c -r example.nim --out:bin/example.o
nim c -r example.nim -o:example.o
nim c -r example.nim --out:example.o
所有这些尝试的结果与我遗漏 -o/--out
选项的结果相同,导致在与 example.nim
文件相同的文件夹中生成可执行文件 example
.如果我不传入 -r
选项,编译器甚至不会接受该选项(这让我觉得我误解了该选项的用途)。
我正在使用从 github devel
分支源安装和编译的 Nim 0.10.3。
哪个编译器选项允许我修改编译后的输出文件?
你做的是对的,但选项必须在你正在编译的文件之前。您指定 -r
以在编译后执行文件,因此它将是 运行 并在文件后指定所有参数。
所以这应该有效:
nim c -o:bin/example -r example.nim
nim c -o=bin/example -r example.nim
nim c --out:bin/example -r example.nim
nim c --out=bin/example -r example.nim