make:'exit_status.c'什么都不做

问题描述 投票:0回答:1

我不能编译我写的任何代码。每当我输入“make”时,错误信息是:

make: Nothing to be done for '*FILE*'

除了问题,

cs50.h
总是下划线是红色的

我正在使用 visual studio 代码。

#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
}

起初在终端中无法识别 make 命令。所以我在观看了 youtube 视频后设法安装了它。每当我打电话给它时,它就会来,但它并不像讲师的机器那样工作。

这是我的终端文本:

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>

根据最后一条评论,我意识到最好是获得一个 linux 环境。所以我安装了具有 ubuntu 功能的 linux。我的界面看起来更像在 Youtube 上教授 cs50 课程的教授的界面。 make的安装也成功了。但是,我遇到了另一个问题:

dillon@OPTIMUS:~$ make hello_world cc hello_world.c -o hello_world make: cc: 没有那个文件或目录 make: *** [: hello_world] 错误 127

我把路径添加到我的系统路径中,还是没有解决问题。我添加的路径是hello_world.c文件的路径

c visual-studio-code makefile cs50
1个回答
0
投票

你需要创建一个

Makefile
文件,没有它,
make
不知道该怎么办。

例子:

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

在伪代码中是:

target : requirements
    command using requirements to create target

只有这样你才能期待

make target
的东西。 现在你可以执行命令
make exit_status
.

更多阅读:https://makefiletutorial.com/

© www.soinside.com 2019 - 2024. All rights reserved.