Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, I am getting the error: Undefined reference to main: Please guide me how can i get rid of this. Regards, Mayank...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    7

    Error in main

    Hi all,

    I am getting the error:

    Undefined reference to main:

    Please guide me how can i get rid of this.

    Regards,
    Mayank

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Your sourcecode compiles fine because there are no syntactical errors.
    But after that the linker tries to build a executable out of it and therefor needs to know some "start-position" where the work begins when your programme is started later. Per default this is a function called "main" and it seems yours is missing or the linker can't find it.

    (I assumed you want to build an executable.)

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by amayank77 View Post
    Hi all,

    I am getting the error:

    Undefined reference to main:

    Please guide me how can i get rid of this.

    Regards,
    Mayank
    It's hard to guess what you mean.

    Post your source code, or if it's big, paste it in pastebin.com and then link it here so we can see it.

    As the poster above says, all C programs need a "main" function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...