Hello, I am very new to this language, I have a compiler/linker question. When I compile my program (Windows platform) with: nim c -d:release myproject.nim
I then notice some sections in the resulting executable named things like /19 containing paths to the gcc directory etc. Do I need to pass some parameter to gcc to strip symbols or some such?
Can someone provide a sample commandline for a lean executable that can be distributed (and has no dependencies of course)
If you need smaller binary -d:release --opt:size.
Linux and OsX should have a strip command to strip binaries with strip --strip-all.
I think MinGW has that on Windows too.
Thank you. I just compile with nim -d:release --opt:size c greetings.nim myprog.nim
and then strip --strip-all myprog.nim
Now a simple program is just 36k, nice and lean if I want to distribute it.
no need to call strip, use --passL, see:
nim c -d:release --opt:size --passL:-s app.nim
Ah, thanks, now I created a batch file containing nim c -d:release --opt:size --passL:-s %1
and just use that one from the cmdline. I guess you can put a pause as a second command and drag'n'drop nim a file on it.
If you're compiling from specific directory, you can add nim.cfg with option like
-d:release
--opt:size
--passL:-s
and you can compile normally nim c -r myprog.nim
If you want a specific configuration for a file, you can name it as myprog.nim.cfg if your file is myprog.nim the options will be applied only for that file.
I then notice some sections in the resulting executable named things like /19 containing paths to the gcc directory etc.
Is this really the default behavior? I would not like to include string paths inside my binaries. Would it make sense to strip this information by default?