Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Nim compiler output file location and name

Tags:

nim-lang

Compiling a Nim program with nim c -r example.nim creates the output file example. I would like to create an output file in another folder with the name bin/example.o which is much easier to gitignore.

What I've tried so far:

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

The result of all of these attempts is the same as if I left out the -o/--out option, resulting in an executable example file in the same folder as the example.nim file. The compiler doesn't even accept the option if I don't pass in the -r option (which makes me think I'm misunderstanding the purpose of that option).

I'm using Nim 0.10.3 installed and compiled from the github devel branch source.

What compiler option will allow me to modify the compiled output file?

like image 678
Matt Smith Avatar asked Apr 08 '15 21:04

Matt Smith


1 Answers

What you're doing is right, but the options have to be before the file you're compiling. You specify -r to execute the file after compilation, so it will be run with all the arguments specified after the file.

So this should work:

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
like image 50
def- Avatar answered Oct 21 '22 15:10

def-