Results 1 to 3 of 3

Thread: ld returned 1 exit status

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Answers
    2

    ld returned 1 exit status

    when I tried to compile, an error occured.

    # gcc -o prog21_1 prog21_1.c
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start':
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference to `main'
    collect2: ld returned 1 exit status

    what does it means ...???


  2. #2
    Contributing Member
    Join Date
    Apr 2007
    Answers
    58

    Re: ld returned 1 exit status

    Forgot to add 'main' function in the program ie. int main ( blah..blah)? If you get error again and you are trying to compile c++, try using g++ instead of gcc.

    Regards,
    Anoop :)
    If its useful, dont forget to [COLOR="Red"]THANK[/COLOR] me :cool:

  3. #3
    Junior Member
    Join Date
    Apr 2007
    Answers
    2

    Re: ld returned 1 exit status

    Haitalk

    As you pointed out, I didn't use 'main' function...

    First time, I wrote as follow.

    -----------------------------------------
    int sub_proc(int a, int b, int c)
    {
    int buf[5];

    buf[0]=a;
    buf[1]=b;
    buf[2]=c;
    return(2);
    }
    int testproc()
    {
    sub_proc(1,2,3);
    return(1);
    }
    ------------------------------------------

    This code is just for studying assembler code about 'preserve rocal buffer', 'function call', etc..
    And I rewrote it as your advice.

    -----------------------------------------
    int sub_proc(int a, int b, int c)
    {
    int buf[5];

    buf[0]=a;
    buf[1]=b;
    buf[2]=c;
    return(2);
    }
    int testproc()
    {
    sub_proc(1,2,3);
    return(1);
    }

    main()
    {
    testproc();
    return 0;
    }
    ------------------------------------------

    I could compile and disassemble !!
    Thank you so much !!

    Last edited by jsk_08; 04-17-2007 at 11:40 AM.

  4.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact