Thread: error: ld returned 1 exit status

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    93

    error: ld returned 1 exit status

    What is error: ld returned 1 exit status in program

    Code:
    #include <stdio.h>
    int main (void)
    { 
        int number;    
        printf("promote numbers  :");
        scanf("%d",&number);
       switch (number)
       {
          
       case 1: 
       print("Grade 1");
       break;
       
       case 2:
       print("Grade 2");
       break;
       
       case 3:
       print("Grade 3");
       
       default: 
       print ("Error");
       }
        return 0;
       
    }
    compiler error

    C:\Users\MREMBE~1\AppData\Local\Temp\ccwNKKC0.o:he llo.c.text+0x49): undefined reference to `print'
    C:\Users\MREMBE~1\AppData\Local\Temp\ccwNKKC0.o:he llo.c.text+0x57): undefined reference to `print'
    C:\Users\MREMBE~1\AppData\Local\Temp\ccwNKKC0.o:he llo.c.text+0x65): undefined reference to `print'
    C:\Users\MREMBE~1\AppData\Local\Temp\ccwNKKC0.o:he llo.c.text+0x71): undefined reference to `print'
    collect2.exe: error: ld returned 1 exit status

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    25,782
    You tried calling the non-existent function print when you probably wanted to call printf from <stdio.h>
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    93
    Quote Originally Posted by laserlight View Post
    You tried calling the non-existent function print when you probably wanted to call printf from <stdio.h>
    Can you tell me, How to fix error ?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    36,119
    You open the source file and do a search for print.
    Decide which need to become printf.

    Seriously.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Apr 2012
    Posts
    93
    Quote Originally Posted by Salem View Post
    You open the source file and do a search for print.
    Decide which need to become printf.

    Seriously.
    I am sorry but still I can't figure out exact error in program

    This program is running without error.
    Code:
    #include<stdio.h>
    int main(void)
     {
      
      int number;
      printf("  Promote user : ");
      scanf("%d",&number);
      switch (number)
       {
         case 1:
          printf("Grade 1");
          break;
         case 2:
          printf("Grade 2");
          break;
         case 3:
          printf("Grade 3");
          break;
         case 4:
          printf("Grade 4");
          break;
         default: 
        printf("Error");
       }    /* end of switch */
     return 0;
     }
    Promote user : 3
    Grade 3

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    3,297
    Do you not understand that "printf" and "print" are not the same words?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  7. #7
    Registered User
    Join Date
    Apr 2012
    Posts
    93
    Quote Originally Posted by stahta01 View Post
    Do you not understand that "printf" and "print" are not the same words?

    Tim S.
    Thanks. I missed it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Error] Id returned 1 exit status
    By iyilikpenisi in forum C Programming
    Replies: 6
    Last Post: 09-16-2016, 02:28 PM
  2. collect2.exe: error: ld returned 1 exit status
    By umutefiloglu in forum C Programming
    Replies: 4
    Last Post: 05-11-2014, 09:37 AM
  3. collect2: ld returned 1 exit status error??
    By blindchicken11 in forum C Programming
    Replies: 11
    Last Post: 11-07-2011, 08:38 PM
  4. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  5. ERROR collect2: ld returned 1 exit status
    By meili100 in forum C++ Programming
    Replies: 13
    Last Post: 12-04-2007, 12:20 PM

Tags for this Thread