There are two simple .c files add.c and hello.c. this is my makefile-
all: add.exe hello.exe
add.exe: add.o
gcc -o add.exe add.o
hello.exe: hello.o
gcc -o hello.exe hello.o
add.o: add.c
gcc -c add.c
hello.o: hello.c
gcc -c hello.c
on typing make
on terminal it shows all those four commands, but when i try to run this using ./all
it says
bash: ./all: No such file or directory.
./hello.exe
or ./add.exe
works fine.
when I type ./all on my friend's pc, it shows proper output.
Your friend's PC is doing something strange and its not clear from your question what they've done. Your PC is acting normally.
Calling make all
Will compile everything, but it doesn't actually make a program called all
. It only compiles two programs: hello.exe
and add.exe
.
So calling ./all
should fail because that is asking to run a program called all
which doesn't exist.
It's quite possible that your friend has written themselves a program or script called "all". You'll need to ask your friend what that script / program does and how it does it.
Edit
To see what your friend has done open a terminal on your friends pc (like the one in your screen shot) and type the command
ls -lh
This will list all the files in that directory. Look for one named "all". It might look something like this (with the word "all" in green):
-rwxr----- 1 appy appy 67 Oct 23 15:05 all
Assuming that's there you can look at the contents of it by typing
cat ./all
To get yours to work like your friends, create a similar file with the same contents. To make it runnable you may need to change the file permissions:
chmod u+x all
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With