1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

配置Nim的默认编译参数 release build并运行

Last updated at Posted at 2018-01-18

配置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,一行一个参数:

nim.cfg
# 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

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?