简体   繁体   中英

Makefile can't find file in same directory

Okay so here is my current directory arch.c archmake.c archsearch.c rearch.c makefile in.txt

The error I'm getting is 'ake: Fatal error: Don't know how to make target 'arch.c

And here is my makefile

prog: arch.o archmake.o archsearch.o rearch.o
    gcc arch.o archmake.o archsearch.o rearch.o -o prog
arch.o: arch.c
    gcc -c arch.c
archmake.o: archmake.c
    gcc -c archmake.c
archsearch.o: archsearch.c
    gcc -c archsearch.c
rearch.o: rearch.c
    gcc -c rearch.c

I am at a loss I feel like ever thing is spelled out. Every thing compiles and works if I type out the commands and don't use the make file.

Look at the error message very closely. The file name listed at the end of the line is

`arch.c

with an unmatched quote. At the beginning of the line is another quote. I suspect your file is actually named arch.c^M , with the last character being a 'carriage-return' character. Try listing the contents of the directory with ls -b .

If so, then you can rename the file with

mv arch.c* tmp
mv tmp arch.c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM