collect2 错误 ld 返回 1 退出状态 c 程序,函数 "wait"

collect2 error ld returned 1 exit status c program with function "wait"

我正在尝试通过实用程序在终端中制作一个简单的 c 程序,它显示如下:

root@alireza:~/Documents/gnuc++/3/wait# make
gcc wait.o -o wait
/usr/bin/ld: cannot open output file wait: Is a directory
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
root@alireza:~/Documents/gnuc++/3/wait# gcc -o wait wait.c
/usr/bin/ld: cannot open output file wait: Is a directory
collect2: error: ld returned 1 exit status
root@alireza:~/Documents/gnuc++/3/wait#

如上所示,我手动编译了wait.c文件,但是又报错了(无论是gcc还是g++)。 :(

不知道是编译器的问题还是我的方法不对

我正在使用 Kdevelop IDE 并且它有效。

wait.c file

 #include<stdio.h>
 #include<stdlib.h>
 #include<sys/wait.h>
 #include<unistd.h>  
 int main() {
     pid_t cpid;
     if (fork()== 0)
         exit(0);           /* terminate child */
     else
         cpid = wait(NULL); /* reaping parent */
     printf("Parent pid = %d\n", getpid());
     printf("Child pid = %d\n", cpid);

     return 0;
}

Makefile

 cc=gcc

 all: wait.o 
     $(cc) wait.o -o wait

 wait.o:
     $(cc) -c wait.c -o wait.o

 clean:
     rm -rf *.o wait    clear

使用make还是手动编译应该怎么办?

感谢任何有关此的帮助和提示。

显然您的输出目录中有一个名为 "wait" 的文件夹,请尝试将您的输出重命名为 wait.out .