Error: Multiple definition of '_main'...

HI,
As u may think, I am new to C programing and as I was making programs in C, my first program was successfully compiled while all the programs that followed contained load of errors; the main being
<<Error: Multiple definition of '_main'>>
I think that the first program that was compiled has a 'main' that links with all the other programs that I want to create.
Can anyone tell me what is the way out for creating other programs without this error??
By the way, I am using DJGPP's C compiler on a win98 PC.
Is there something that I have to change the properties anywhere??
Any help appreciated.

Comments

  • : HI,
    : As u may think, I am new to C programing and as I was making programs in C, my first program was successfully compiled while all the programs that followed contained load of errors; the main being
    : <<Error: Multiple definition of '_main'>>
    : I think that the first program that was compiled has a 'main' that links with all the other programs that I want to create.
    : Can anyone tell me what is the way out for creating other programs without this error??
    : By the way, I am using DJGPP's C compiler on a win98 PC.
    : Is there something that I have to change the properties anywhere??
    : Any help appreciated.
    :


    Only one, and only one, *.c or *.cpp file can have a function called main(). check all the files you are linking together to see how many have main() defined.
  • : : HI,
    : : As u may think, I am new to C programing and as I was making programs in C, my first program was successfully compiled while all the programs that followed contained load of errors; the main being
    : : <<Error: Multiple definition of '_main'>>
    : : I think that the first program that was compiled has a 'main' that links with all the other programs that I want to create.
    : : Can anyone tell me what is the way out for creating other programs without this error??
    : : By the way, I am using DJGPP's C compiler on a win98 PC.
    : : Is there something that I have to change the properties anywhere??
    : : Any help appreciated.
    : :
    :
    :
    : Only one, and only one, *.c or *.cpp file can have a function called main(). check all the files you are linking together to see how many have main() defined.
    :

    As I am new to C programing, I dont know about the linking of the *.c files. What I mean to say is that first I made my first C program named 'HelloWorld.c' and next I wanted to make another C program relating to addition of 2 numbers .
    Now, HelloWorld.c runs perfectly without errors, but the other programs that I want to write, are not compiled properly and are with loads of errors that I don't think have any.
    i.e. add.c when compiled says:::
    Error: Multiple definition of '_main' with other errors following it.
    When I point to this error, the DJGPP program takes me back to the 'main' statement I wrote in HelloWorld.c .

  • I think I found the problem. I am posting this for those who are going thru a similar experience.
    In my computer, DJGPP considers all the .c programs written one after the other are read as a single project that does not require the repetitive codes such as 'main'...
    However, I do not know how to make single programs work as their own entity and not as a whole project.
    So, now I am using Turbo C which does not have the same facility (/annoyance).

    Anyways, for me as a beginner of C language, Turbo C is a CLASSIC compiler, though old/ outdated; it works for ME.
    Thanks for your replies.
  • : I think I found the problem. I am posting this for those who are going thru a similar experience.
    : In my computer, DJGPP considers all the .c programs written one after the other are read as a single project that does not require the repetitive codes such as 'main'...
    : However, I do not know how to make single programs work as their own entity and not as a whole project.
    : So, now I am using Turbo C which does not have the same facility (/annoyance).
    :


    download Dev-C+++ from www.bloodshed.net -- a very good modern 32-bit [b]free[/b] compiler that is well supported.
  • [b][red]This message was edited by thunderdome at 2006-1-22 23:58:35[/red][/b][hr]

    Thanks all,
    I was just surfing the web when I came up to a forum that replied to me that ( DJGPP compiles all open files into one exe, even if you don't have a project open. Close your other file[s] and it will compile just fine. )
    I seached all the menus in DJGPP and found that the close button was located on Windows menu (shortcut Alt+F3). But then again whenever now I try to run any new programs in c the rhide hangs itself up without showing any result screen. May be because of some insufficient memory.
    Anyway now I use Borland to peacefully type the programs. I was suggested that there are other ''compilers'' such as gvim and xterm (editors) which are good.
    Thanks all for their time and replies.

    DJGPP is much better than Turbo C as I was suggested. So folks out there, plz use a modern compiler rather than making a mistake that I made. ( DEV C++ is a good compiler too. :-) )


    I wonder how did the strikethrough lines appear in every line here???
  • You have enclosed the s between [leftbr] [rightbr] which is the code for strikethrough tag on these forums. Since you haven't closed the strikethrough tag, it spanned to all the other lines.

    :
    : (...) Close your other file[leftbr]s[rightbr] (...)
    :
    : (...) I wonder how did the strikethrough lines appear in every line here???
    :

    Homero C. de Almeida

    [italic]There's no dishonour in failure. For we aren't allowed to know wheter we'll achieve success or not. There is only one final shame, the cowardice of not trying.[/italic]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories