How to change the location and name of the output file of the Nim compiler

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

What I have 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 these attempts is the same as if I left the -o/--out option, as a result of which the example executable file was in the same folder as the example.nim file. The compiler does not even accept a parameter unless I pass the -r parameter (which makes me think that I do not understand the purpose of this parameter).

I am using Nim 0.10.3, installed and compiled from a github devel branch source.

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

+5
source share
1 answer

What you are doing is correct, but the parameters must be before the file you are compiling. You specify -r to execute the file after compilation, so it will 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 
+3
source

All Articles