zoukankan      html  css  js  c++  java
  • make error: makefile:4: *** missing separator. Stop

    • Question:

    This is my makefile:

    all: hello.o
    
    hello.exe: hello.o
        gcc -o hello.exe hello.o
    
    hello.o: hello.c
        gcc -c hello.c
    
    clean:
        rm hello.o hello.exe
    

    When I try to make clean or make make, I get this error:

    :makefile:4: *** missing separator. Stop.
    How can I fix it?


    makefile has a very stupid relation with tabs, all actions of every rule are identified by tabs ...... and No 4 spaces don't make a tab, only a tab makes a tab...

    to check I use the command cat -e -t -v makefile_name

    It shows the presence of tabs with ^I and line endings with $ both are vital to ensure that dependencies end properly and tabs mark the action for the rules so that they are easily identifiable to the make utility.....

    Example:

    Kaizen ~/so_test $ cat -e -t -v  mk.t
    all:ll$      ## here the $ is end of line ...                   
    $
    ll:ll.c   $
    ^Igcc  -c  -Wall -Werror -02 c.c ll.c  -o  ll  $@  $<$ 
    ## the ^I above means a tab was there before the action part, so this line is ok .
     $
    clean :$
       
    m -fr ll$
    ## see here there is no ^I which means , tab is not present .... 
    ## in this case you need to open the file again and edit/ensure a tab 
    ## starts the action part
    

    hope this helps !!


    makefile中要在shell中执行的命令必须要用tab开头,而make语句用空格即可

    :

    第8行和第10行用tab

    ifneq ($(KERNELRELEASE),)
        obj-m += module.o
    else
        PWD := $(shell pwd)
        KVER := $(shell uname -r)
        KDIR := /lib/modules/$(KVER)/build
    all:
            $(MAKE)    -C $(KDIR) M= $(PWD)
    clean:
            rm -rf *.o *.mod.c *.ko *.symvers *.order *.makers
    endif
    

    其他问题,如编码格式,中文、日文字符,文件开头有BOM标记等

    查看前20个字符,每行显示10个字符:

    $ xxd -l 20 -c 10 makefile
    00000000: 616c 6c3a 2068 656c 6c6f  all: hello
    0000000a: 2e6f 0a0a 6865 6c6c 6f2e  .o..hello.
    
  • 相关阅读:
    nginx proxy_cache 缓存配置[转]
    MongoDB使用小结:一些常用操作分享
    PHP读取Mongodb数据报错,Cannot natively represent the long 8331412483000 on this platform
    MongoDB 学习笔记(python操作)
    Python 中 os.path模板
    Python 优雅的操作字典【转】
    MongoDB 一对多关系建模
    nginx之location配置
    MongoDB安装Windows服务
    .net4.0 请求HTTPS出错:未能创建 SSL/TLS 安全通道
  • 原文地址:https://www.cnblogs.com/minding/p/11864869.html
Copyright © 2011-2022 走看看