2

My code is correct but when I write Make hello in the terminal, there is an error.

I expected Hello World to appear but there was an error instead, even when everything was correct. This is what my code looks like:

#include <stdio.h>

int main(void)
{
    printf ("hello, world");
}

This is what it says when I type "make hello":

PS C:\Harvard Tutorial> make hello
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling ofthe name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ make hello
+ ~~~~    + CategoryInfo          : ObjectNotFound: (make:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Hackaholic
  • 19,069
  • 5
  • 54
  • 72
Amaaz28
  • 21
  • 2
  • 1
    Do you have `make` installed and on your PATH (or whatever Windows calls it)? – ndc85430 Dec 29 '22 at 16:48
  • 1
    Make needs to be installed. On Windows, you can install it from [MSYS2](https://stackoverflow.com/q/30069830/2752075) using `pacman -S make`. It will be installed to `C:\msys64\usr\bin\make.exe`, so that directory must be in the PATH. – HolyBlackCat Dec 29 '22 at 16:49
  • Note also that `make` _compiles_ the program; it doesn't _run_ it. – ndc85430 Dec 29 '22 at 16:49
  • I installed make right now but I don't know how to add path – Amaaz28 Dec 29 '22 at 17:04
  • (Assuming you're on Windows): you can add "C:\msys64\usr\bin" to your %PATH% variable like this: 1) Start > This PC > Properties > Advanced System Settings > Environment Variables > System environment variables > Path > Edit. See also: https://code.visualstudio.com/docs/cpp/config-mingw – paulsm4 Dec 29 '22 at 17:10

3 Answers3

1

You need to install MinGW-w64 in your Windows machine. After that add C:\msys64\mingw64\bin to the path. You can do that by going to the control panel then go to System then Advanced system settings and then Environment variables. In that go to system variables, then to Path, and then add C:\msys64\mingw64\bin to the path.

To learn more, checkout this guide.

0

Try to open the CMD (not the powershell) and write

where make

this shoud show the position for the exe of "make" if it is in the path inside the Windows Ambient Variables.

If show a information like "unable to find", add "make" into the Windows Ambient Variables (in the path variable) and restart your pc

Stefifox
  • 24
  • 3
-1

For you example you can just use gcc hello.c. To use Make you need create a makefile google cmake and that will help you generate a makefile.

Chuck
  • 49
  • 1
  • 4