zoukankan      html  css  js  c++  java
  • makefile格式实践一

    一直知道makefile是为了让工程更合理化编译和输出~

    从未在unix下自己写这个;在windows开发中一直用ide开发,ide自带;偶而写写小东西,也是用bat方式直接编译。

    ps:bat方式就是自己写编译命令;与makefile的区别是前者无论文件是否发生改变都编译,后者是当编译成功后若文件未发生任何改动,不会编译;较之于前者,后者编译效率高的多。

    以前简单学习了makefile,没有动手实践过;今天有兴致简单实践一把。

    实际环境:

    net cs代码

    nmake

    编写简单代码:helloworld

    1 using System;
    2  using System.Collections.Generic;
    3  using System.Text;
    4
    5  namespace ConsoleApplication1
    6 {
    7 class Program
    8 {
    9 static void Main(string[] args)
    10 {
    11 string s = "Hello";
    12 s = s + " world";
    13
    14 Console.WriteLine(s);
    15
    16 Console.Read();
    17 }
    18 }
    19 }
    20  

    第一次编写makefile,如下:

    1 all:helloworld.exe
    2
    3 helloworld.exe:helloworld.cs
    4 csc helloworld.cs
    5
    6 clean:
    7 -del *.exe

    直接用命令:nmake helloworld.makefile

    报错:fatal error U1034

    想了半天,尝试性的做了如下调整:

    1 all:helloworld.exe
    2
    3 helloworld.exe:helloworld.cs
    4 csc helloworld.cs
    5
    6 clean:
    7 -del *.exe

    再使用命令,完全编译通过

    仔细看看两个makefile,发现第四行和第七行有一个空格的差异。

    阅读《How to Write makefile.pdf》其中没有此空格的注明,仅有如下规则:

    target...:prerequisites...

    command

    【总结】:

    实际的格式:

    target...:prerequisites...

     command

    此处空格意义:告知nmake"command"是目标的一个命令,而非下一个目标的开始。

    另外不知道其他情况下,比如unix下是否有这个问题,也许仅仅只有nmake才有这个错误。有待后续测试结论

    【2010-12-28】

    继续阅读《How to Write makefile.pdf》,文中有这么一句:

    最后,还值得一提的是,在Makefile中的命令,必须要以[Tab]键开始。

    此话已说明命令在格式中的特殊起始点。上面所说" "空格不是标准的格式,可用而已

  • 相关阅读:
    第一节:理解垃圾回收平台的基本工作原理
    回想笔记 瞎比比 域名注册 解析绑定ip 下载证书 设置证书 重定向http到https请求
    flask 设置https请求 访问flask服务器
    关于 服务器ip和域名进行一个绑定
    ubuntu 安装flask+nginx+gunicorn 待定
    使用flask-dropzone 上传图片文件
    flask 对于用户登录保持状态 flask_login
    flask 对于邮件url进行一个加密防止爆破
    flask 密码加密 视频资料
    flask 多线程邮件异步发送 视频资料
  • 原文地址:https://www.cnblogs.com/GoGoagg/p/1917998.html
Copyright © 2011-2022 走看看