zoukankan      html  css  js  c++  java
  • Linuxc

    Makefile完成项目的管理。

    root@jiqing-virtual-machine:~/cspace/les2# ls
    main.c  Makefile  max.c  max.h  min.c  min.h
    
    root@jiqing-virtual-machine:~/cspace/les2# gcc max.c min.c main.c -o main.out
    

    这才两个模块,就要写这么多。如果很多的话,岂不是累死。

    这个时候就通过Makefile 进行管理。

    root@jiqing-virtual-machine:~/cspace/les2# make -v
    GNU Make 4.1
    Built for x86_64-pc-linux-gnu
    Copyright (C) 1988-2014 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    

    查看是否安装了make。

    撰写Makefile文件,

    # this is make file
    main.out:max.o min.o main.c
        gcc max.o min.o main.c -o main.out
    max.o:max.c
        gcc -c max.c
    min.o:min.c
        gcc -c min.c
    
    

    注意了,这里的gcc命令前一定是tab6位。

    不可以是4个空格或者6个空格。

    可以通过

    set ts=6
    

    来设置。

    root@jiqing-virtual-machine:~/cspace/les2# make
    gcc -c max.c
    gcc -c min.c
    gcc max.o min.o main.c -o main.out
    
    

    执行完,会发现多了一些文件。

    root@jiqing-virtual-machine:~/cspace/les2# ls
    main.c  main.out  Makefile  max.c  max.h  max.o  min.c  min.h  min.o
    
    
    root@jiqing-virtual-machine:~/cspace/les2# ./main.out 
    the max value is 33
    the min value is 22
    
    

    正常情况下,大型的项目都是通过Makefile文件来进行编译的。

  • 相关阅读:
    eclipse中的项目的JRE换成JDK
    Eclipse中maven项目的创建和运行
    git 发布命令
    vbox中虚拟ubuntu增加新的虚拟硬盘
    MyServer
    java常用的中间件
    高并发解决方案
    浅谈SpringMVC
    浅谈HIbernate
    javaweb笔记七
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/8335340.html
Copyright © 2011-2022 走看看