I cannot compile any of the codes I wrote. Whenever i type 'make' the error message is:
make: Nothing to be done for '*FILE*'
In addition to the problem, cs50.h
is always underlined red.
I'm using visual studio code.
#include <stdio.h>
#include <cs50.h>
int main (int argc, string argv[])
{
if (argc != 2)
{
printf("Error code argccount!2");
return 1; // 1 signals to the computer that something went wrong
}
print("Hello %s\n", argv[1])
return 0; // 0 indicates that all went well
}
At first the make command wasn't recognizable in the terminal. So I manage to install it after watching a youtube video. Whenever i call make it comes but then it doesn't just work like how the lecturer's machine does.
This is my terminal text:
PS C:\Users\`~d L n\Desktop\Folders\CS50> make exit_status.c make: Nothing to be done for 'exit_status.c'. PS C:\Users\`~d L n\Desktop\Folders\CS50> make exit_stat make: *** No rule to make target 'exit_stat'. Stop. PS C:\Users\`~d L n\Desktop\Folders\CS50> make foo make: *** No rule to make target 'foo'. Stop. PS C:\Users\`~d L n\Desktop\Folders\CS50>
Following the last comment, I realized the it was better to get a linux environment. So I installed linux with ubuntu feature. My interface looks much more similar to that of the professor who is teaching the cs50 course on Youtube. Installation of make was also successful. However, I'm encountering another problem:
dillon@OPTIMUS:~$ make hello_world cc hello_world.c -o hello_world make: cc: No such file or directory make: *** [: hello_world] Error 127
I added the path to my system path, but it still didn't solve the problem. The path I added was the path of the hello_world.c file
You need to create a Makefile
file, without which, make
does not know what to do.
Example:
exit_status: exit_status.o
cc exit_status.o -o exit_status
exit_status.o: exit_status.c
cc -c exit_status.c -o exit_status.o
Which is, in pseudo code:
target : requirements
command using requirements to create target
only then you can expect something from make target
.
Now you can execute the command make exit_status
.
More to read: https://makefiletutorial.com/