I want to use make to compile my c programs, but make seems to throw an error when simply using gcc doesn't.
What I tried:
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ ls
makefile test.c
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ gcc test.c -Wall -o test
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ ls
makefile test test.c
The same result is expected with using gcc through make, but what I got is:
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ ls
makefile test.c
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ make
gcc test.c -o test
make: gcc: No such file or directory
make: *** [makefile:2: default] Error 127
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ ls
makefile test.c
The contents of makefile and test.c are as follows:
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ cat makefile
default: test.c
gcc test.c -o test
clean:
rm test
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ cat test.c
int main() {
return 0;
}
The versions of gcc and make are as follows:
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ gcc --version
gcc-11 (Debian 11.3.0-1) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
┌──(jimmy㉿DESKTOP-83QC1V9)-[~/programing/personal/test]
└─$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 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.