How to change Nim compiler output file location and name
Asked Answered
H

1

9

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?

Homogenize answered 8/4, 2015 at 21:26 Comment(0)
D
10

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
Dauphine answered 8/4, 2015 at 22:22 Comment(1)
This shows in help via nim --fullhelp | grep '\-\-out:'.Andrew

© 2022 - 2024 — McMap. All rights reserved.