C compile error: Id returned 1 exit status

247,714

Solution 1

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.

Solution 2

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.exe returns 1 when it can't access required files. This usually includes

  • 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)

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

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.exe from writing the new linked program to it.

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

Share:
247,714

Related videos on Youtube

C_Intermediate_Learner
Author by

C_Intermediate_Learner

I am taking a course in C and am currently in the final part of the course

Updated on July 09, 2022

Comments

  • C_Intermediate_Learner
    C_Intermediate_Learner almost 2 years

    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

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

    • Joachim Isaksson
      Joachim Isaksson almost 11 years
      Could you please add your program and the compiler command you're using to compile it?
  • C_Intermediate_Learner
    C_Intermediate_Learner almost 11 years
    It still gives the same error message after killing the task. Is there possibly something wrong with the code?
  • Bugs Happen
    Bugs Happen over 7 years
    Exactly, restarting my PC solved the problem (couldn't kill manually because I couldn't find the running program in Task Manager)
  • Siraj Alam
    Siraj Alam over 6 years
    Please edit your answer and provide some more information. Your answer looks like a comment rather than an answer.
  • colidyre
    colidyre over 5 years
    To what extent is that an answer to the question?

Related