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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With