C语言 C 编译错误:Id 返回 1 个退出状态

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17717946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 06:56:34  来源:igfitidea点击:

C compile error: Id returned 1 exit status

ccompiler-errorspermission-denied

提问by C_Intermediate_Learner

For some reason, when I try compiling a program, the compiler says permission denied and Id returned 1 exit status. Could anyone tell me what that means? Thank you

出于某种原因,当我尝试编译程序时,编译器说权限被拒绝并且 Id 返回 1 退出状态。谁能告诉我这是什么意思?谢谢

#include <stdio.h>                                               /* Library inclusions */
#include "genlib.h" 
#include "simpio.h"

int binSearch(int val, int numbers[], int size1);                /* prototypes */
void sortArray (int numbers[], int size1);                       
int indexMax (int numbers[], int low, int high);
void swap (int numbers[], int loc, int loc1);
void getArray (int numbers[], int size1);
void displayArray (int numbers[], int size1);

main()
{
  int value, size1;

  printf("Enter the number of elements: ");
  size1=GetInteger(); 
  int numbers[size1];
  getArray(numbers, size1); 
  sortArray(numbers, size1); 
  displayArray(numbers, size1);
  printf("\nEnter value to find: ");
  value=GetInteger();
  binSearch(value, numbers, size1);
  getchar();
}

void sortArray (int numbers[], int size1)                        /*Function sortArray*/
{
 int i , maxInd;

 for (i= size1-1; i>=0;i--)
 {
     maxInd=indexMax(numbers, 0, i);
     swap (numbers, i, maxInd);
 }
}

void displayArray (int numbers[], int size1)                     /*Function displayArray*/
{
 int i;

 printf("This is the sorted set of numbers: \n");
 for (i=0; i< size1; i++)
 {
         printf ("%d\t", numbers[i]); 
     }
}

void getArray (int numbers[], int size1)                         /*Function getArray*/
{
 int i;

 for (i=0; i<size1; i++)
 {
     printf ("Enter the values of the %d elements: ", size1);
     numbers[i]=GetInteger();
 }
}

int indexMax (int numbers[], int low, int high)                  /*Function indexMax*/
{
int i, maxInd;

maxInd=high;
for (i=low;i<=high;i++)
{
    if (numbers[i]>numbers[maxInd]) 
    {
                   maxInd =i;
    }
    }
    return (maxInd);
}

void swap (int numbers[], int loc, int loc1)                     /*Function swap*/
{
 int temp;

 temp=numbers[loc];
 numbers[loc]=numbers[loc1];
 numbers[loc1]=temp;
}

int binSearch(int val, int numbers[], int size1)                 /*Function binSearch*/
{
 int low, high, mid;

 low=0;
 high=size1-1;
 while(low<=high)
 {
                 mid=(low+high)/2;
                 if(val<numbers[mid])
                 {
                                 high=mid-1;                
                 }            
                 else if(val>numbers[mid])
                 {
                                 low=mid+1; 
                 }   
                 else if(val==numbers[mid])
                 {
                                 printf("Your number is in location %d\n", mid+1);break;    
                 } 
                 else
                 {
                                 printf("Your value is not in the array.");        
                 }
   }
}

The above is the binary search algorithm code I tried to compile.

以上是我尝试编译的二分查找算法代码。

回答by Kane

I may guess, the old instance of your program is still running. Windows does not allow to change the files which are currently "in use" and your linker cannot write the new .exe on the top of the running one. Try stopping/killing your program.

我可能猜想,您程序的旧实例仍在运行。Windows 不允许更改当前“正在使用”的文件,并且您的链接器无法将新的 .exe 写入正在运行的文件的顶部。尝试停止/终止您的程序。

回答by iBug

I bet for sure, that this is because you didn't close the running instance of the program before trying to re-compile it.

我敢肯定,这是因为您在尝试重新编译之前没有关闭正在运行的程序实例

Generally, ld.exereturns 1 when it can't access required files. This usually includes

一般ld.exe无法访问需要的文件时返回1。这通常包括

  • Can't find the object file to be linked (or Access denied)
  • Can't find one or more symbols to link
  • Can't open the executable for writing (or AD)
  • 找不到要链接的目标文件(或Access denied
  • 找不到一个或多个要链接的符号
  • 无法打开可执行文件进行写入(或 AD)

The program looks completely fine, so the second point should not hit. In usual cases, it's impossible for ldto fail to open the object file (unless you have a faulty drive and a dirty filesystem), so the first point is also nearly impossible.

程序看起来完全没问题,所以第二点应该不会命中。在通常情况下,ld打开目标文件是不可能的(除非你的驱动器有问题并且文件系统很脏),所以第一点也几乎是不可能的。

Now we get to the third point. Note that Windows not allow writing to a file when it's in use, so the running instance of your program prevents ld.exefrom writing the new linked program to it.

现在我们进入第三点。请注意,Windows 不允许在使用文件时写入文件,因此程序的运行实例会阻止ld.exe向其写入新的链接程序。

So next time be sure to close running programs before compiling.

所以下次编译前一定要关闭正在运行的程序。

回答by user9110380

You may compiling your program while another program may be running in background. Firstly, see if another program is running .Close it and then try ro compile.

您可能正在编译您的程序,而另一个程序可能正在后台运行。首先,查看是否有其他程序正在运行。关闭它,然后尝试 ro compile。

回答by bb8

Using code::blocks , I have solved this error by doing :

使用 code::blocks ,我通过执行以下操作解决了此错误:

workspace properties > build target > build target files

工作区属性 > 构建目标 > 构建目标文件

and checking every project file.

并检查每个项目文件。

回答by Mallikarjun Ople

Just try " gcc filename.c -lm" while compiling the program ...it worked for me

只需在编译程序时尝试“gcc filename.c -lm”...它对我有用

回答by Sweety

1d returned 1 exit status error

1d 返回 1 个退出状态错误

First of all you have to create a project by clicking file new and then project and give project name select the language c or c++ and select empty also. Then your program is under that project... And then give a program name save it.... Ensure that your under some project to compile and run a program...

首先,您必须通过单击文件新建创建一个项目,然后单击项目并指定项目名称,选择语言 c 或 c++ 并选择空。然后你的程序在那个项目下...然后给一个程序名保存....确保你在某个项目下编译和运行一个程序...

回答by Lu0m0

Is a simple MAYUS word. verify the log.

是一个简单的MAYUS词。验证日志。

回答by anonymous

it could be that you just said main{....I use intmain{ when I start my main.

可能是你刚刚说 main{....I use intmain{ 当我开始我的主要。

回答by Sonadore

This answer is written for C++ developers, because I was haunted by such problem as one. Here is the solution:

这个答案是为 C++ 开发人员写的,因为我被这样的问题困扰。这是解决方案:

Instead of

代替

main()
{

}

please type

请输入

int main()
{

}

so the main function can be executed.

这样就可以执行main函数了。

By the way, if you compile a C/C++ source file with no main function to execute, there will definitely be a bug message saying:

顺便说一句,如果你编译一个没有main函数执行的C/C++源文件,肯定会有一个错误信息说:

"[Error] Id returned 1 exist status"

“[错误] ID 返回 1 个存在状态”

But sometimes we just don't need main function in the file, in such a case, just ignore the bug message.

但有时我们只是不需要文件中的 main 函数,在这种情况下,只需忽略错误消息。

回答by ZUBA

My solution is to try to open another file that you can successfully run that you do at another PC, open that file and run it, after that copy that file and make a new file. Try to run it.

我的解决方案是尝试打开另一个文件,您可以在另一台 PC 上成功运行该文件,打开该文件并运行它,然后复制该文件并创建一个新文件。尝试运行它。