配置Nim的默認編譯參數 release build并運行
默認情況下nim編譯是debug build,如果需要release build, 需要加上-d:release ,
release編譯的命令如下:
nim c -d:release xx.nim
release build并運行:
nim c -r -d:release xx.nim
debug build出來可執行文件體積稍大,并且目前對來我說沒有用。
我發現通過配置nim.cfg,可以給nim編譯器配置默認的編譯參數,nim.cfg文件位于nim的安裝目錄/config下。
類似如下在nim.cfg中添加參數r和d:release,一行一個參數:
# Configuration file for the Nim Compiler.
# (c) 2017 Andreas Rumpf
# Feel free to edit the default values as you need.
# You may set environment variables with
# @putenv "key" "val"
# Environment variables can be accessed like so:
# gcc.path %= "$CC_PATH"
cc = gcc
r
d:release
...
...
...
之后當你執行nim c xx.nim
的時候,配置文件中參數自動傳送給Nim編譯器:
等于 nim c -r -d:release xx.nim
2018-01-18 18:30:00 codegay