版本1和6间的区别 (跳过第5版)
于2010-01-31 19:36:26修订的的版本1
大小: 234
编辑: 116
备注:
于2010-01-31 20:30:14修订的的版本6
大小: 960
编辑: 116
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 1: 行号 1:
== 命令 ==
行号 5: 行号 6:
}}}清除生成的文件。 }}}清除生成的文件。如果要在编译时,少输出一些调试信息,可以用{{{
% scons -Q
}}}如果要在一个子目录中编译,可以用{{{
% scons -u
}}}
行号 7: 行号 12:

最简单的脚本
== 脚本 ==
最简单的脚本,编译main.cc为可执行程序:
行号 12: 行号 17:

编译多个程序为一个可执行程序:
{{{#!python
Program(["main.cc", "hello.cc"])
}}}

编译为目标文件,然后链接成可执行程序:
{{{#!python
objs = Object(["hello.cc", "main.cc"])
Program(objs)
}}}

编译为静态库文件:
{{{#!python
Library("hello.cc")
}}}或者{{{#!python
StaticLibrary("hello.cc")
}}}或者{{{#!python
SharedLibrary("hello.cc")
}}}

链接库文件到程序
{{{#!python
lib = StaticLibrary("hello.cc")
Program("main.cc", LIBS=lib)
}}}

命令

在程序目录下创建一个SConstruct文件,写上脚本,然后执行

% scons

就可以进行编译了。执行

% scons -c

清除生成的文件。如果要在编译时,少输出一些调试信息,可以用

% scons -Q

如果要在一个子目录中编译,可以用

% scons -u

脚本

最简单的脚本,编译main.cc为可执行程序:

   1 Program("main.cc")

编译多个程序为一个可执行程序:

   1 Program(["main.cc", "hello.cc"])

编译为目标文件,然后链接成可执行程序:

   1 objs = Object(["hello.cc", "main.cc"])
   2 Program(objs)

编译为静态库文件:

   1 Library("hello.cc")

或者

   1 StaticLibrary("hello.cc")

或者

   1 SharedLibrary("hello.cc")

链接库文件到程序

   1 lib = StaticLibrary("hello.cc")
   2 Program("main.cc", LIBS=lib)
ch3n2k.com | Copyright (c) 2004-2020 czk.