zoukankan      html  css  js  c++  java
  • [SCons 有点翻译的scons学习] 1. 简单编译

    安装scons

    =====

    这个就不详细说了,嫌麻烦可以直接sudo apt-get install scons。不嫌麻烦去下载源码安装。


    简单编译

    =====

    来看一个最简单的hello, world程序
    int
    main()
    {
        printf("Hello, world!\n");
    }
    然后创建一个SConstruct文件,编写
    Program('hello.c')

    这个最简单的自动化编译文件有两条信息。第一指出了需要编译的结果是一个可执行文件,第二指出了输入文件是
    hello.c。
    这时在命令行终端运行scons,就能自动编译了。
          % scons
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Building targets ...
          cc -o hello.o -c hello.c
          cc -o hello hello.o
          scons: done building targets.
    scons只需要知道输入文件的名字,就能自动推导出依赖文件,并且自动找到编译器,这里是gcc。

    Building Object Files

    =====

    除了可以指定输出是可执行文件,还可以指定输出是.o 文件。
          Object('hello.c')
    输出
          % scons
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Building targets ...
          cc -o hello.o -c hello.c
          scons: done building targets.   

    清理工作

    =====

    当编译完输出可执行文件之后,剩下的.o 文件就多余了,这时可以加个 option -c,来执行清理工作。
          % scons
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Building targets ...
          cc -o hello.o -c hello.c
          cc -o hello hello.o
          scons: done building targets.
          % scons -c
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Cleaning targets ...
          Removed hello.o
          Removed hello
          scons: done cleaning targets.      

    SConstruct文件

    =====

    和make 工具类似,Scons 是根据SConstruct 文件来组织编译的,但有一点不同,SConstruct使用的是python的语法,这点比起makefile来就爽多了。

    如果觉得scons在编译的时候输出了太多信息,眼花缭乱,那么加个 -Q,这样scons: 开头的条目就被隐藏不予显示了。
          C:\>scons -Q
          cl /Fohello.obj /c hello.c /nologo
          link /nologo /OUT:hello.exe hello.obj
          embedManifestExeCheck(target, source, env)

    ilding Object Files


  • 相关阅读:
    Codeforces 1045C Hyperspace Highways (看题解) 圆方树
    Codeforces 316E3 线段树 + 斐波那切数列 (看题解)
    Codeforces 803G Periodic RMQ Problem 线段树
    Codeforces 420D Cup Trick 平衡树
    Codeforces 295E Yaroslav and Points 线段树
    Codeforces 196E Opening Portals MST (看题解)
    Codeforces 653F Paper task SA
    Codeforces 542A Place Your Ad Here
    python基础 异常与返回
    mongodb 删除
  • 原文地址:https://www.cnblogs.com/lyyyuna/p/4123922.html
Copyright © 2011-2022 走看看