Menu

Linker error undefined reference to WinMain16

troughton
2005-09-03
2012-09-26
  • troughton

    troughton - 2005-09-03

    i am learning c++ using sams c++ in 10 minutes
    when i get to the code
    #ifndef PromptModuleH
    #define PromptModuleH

    void PauseForUserAcknowledgement(void);

    #endif
    #ifndef PromptModuleH
    #define PromptModuleH

    void PauseForUserAcknowledgement(void);

    #endif
    it gives me the error mesage
    [Linker error] undefined reference to `WinMain@16'
    when i look at the help files for the dev c++ 4.9.9.2 compiler i am using it tells me to go to compiler options and untick the box that says create for win32
    this is not listed in my options can anyone advise me on how to sort this problem out ??

     
    • S. Thomas Bradley

      Hi Everyone:

      If you had bothered to read the thread FAQ - PLEASE READ BEFORE POSTING A QUESTION you would have found your answer. Then you wouldn't have to post this questions and wait around for someone to tell you to read the FAQ's. And then you would be happily programming away and probably have your assignment done by now. So that right now you could be watching TV or playing on your X-Box, and not still have to write your program, which you haven't done yet cause you didn't read the FAQ's.

      http://www.bloodshed.net/dev/faq.html#winmain

      See Ya
      Butch

       
      • troughton

        troughton - 2005-09-06

        if you had botherd to read what i had put you would have seen that having read the FAQ- PLEASE READ BEFORE POSTING A QUESION dose not have the answor to what i asked as i did read that befor posting a question as i dont like to waste my time. i am only lerning c++ and i am coppying what a profesinal has writen so everything that is serposed to be declared is as shown on the question i posted i am just coppying text direct form a highly recognised book that then explanes why the program reacted like it did cause and effect so before trying to insult me in your reply i would be gratefull if you would actuly read my question as i took time to read your faq's befor asking the question

         
    • S. Thomas Bradley

      Troughton:

      I did mean to insult you. Since you say you read the FAQ's, and hopefully you read the one I pointed you to, and based on your response, I will now make the assumption that you simply don't understand what the answer means.

      So, let me go over the basics, if you already know this stuff, then great, but I don't know if you do, so I'll go over it.

      1) While for very simple programs it isn't required, but for almost all else it is, you should always create a 'Project'. When you create a Project you will be given several options as to the type of application (program) you can create. When you are first learning to program, you will be creating simple text based programs. To run these programs you need to create a 'Console' application, do not create a 'Windows' application, or any of the other types that are available.

      2) In ALL C/C++ console programs you must, and it is not optioinal, you must have a function called main(). The error you got "undefined reference to `WinMain@16'" means that you do not have a main() function. The book you are reading should have told you this. (FYI, in all Window applications, instead of having a main(), you must have a WinMain() function).

      So, I am assuming that the program you posted above is your entire program, and I don't see a main() function in it. Actually, all I see are some preprocessor macros and one function prototype, there are no functions at all here, and since there are no actual functions this isn't a program, per se.

      See Ya
      Butch

       
    • Wayne Keen

      Wayne Keen - 2005-09-11

      One point of context on programs that are found in books.

      Even if the author was very dilligent in checking the code (on more than one compiler even) - there is another factor working against them. Time.

      The cycle for publishing a book is long on the scale of releases of compilers, meaning it is entirely possible that code that compiled when the author wrote the section - may not compile by the time you received your book.

      Now, the reality is that many authors are not as dilligent as I posited above. Some never bother to try and compile their code, or the keep verifying that it works. I have seen teachers that will teach non-standard code because, by golly thats the way they learned it, and anything that reflects the nature of the language as it is today is "industrial" programming and they will not dirty their hands with it. (I was literally told that, I am not making it up - and people like that write books too)

      So, failing miserably to make a long story short, the fact that code is enshrined in even a good book does not mean its "correct" - so avoid making that assumption - it will only lead you to dead ends.

      Wayne

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.