C++ undefined reference to WinMain@16 (Code::Blocks)

前端 未结 11 645
挽巷
挽巷 2020-12-09 22:20

I\'m learning C++ with Code::Blocks, and everytime i try to create a new class, I get an error message saying:

undefined reference to `WinMain@16\'


        
相关标签:
11条回答
  • 2020-12-09 22:58

    Fix: undefined reference to `WinMain@16' or undefined reference to 'class-name::class-name()' in codeblocks Error in CodeBlocks

    I had same problem. Actually it was very easy to fix. On Menu bar go to

    project --> build option Put check mark on Have g++ follow the C++11 ISO C++ language standard [-std=c++11]
    then click ok and build and run your project [F9] . click here to see screen capture image. Separate Class files code blocks fix

    0 讨论(0)
  • 2020-12-09 23:02

    I met the problems as well before, my solution is to create a project if you have many files which include head file. By that way, when you code #include "Burrito.h" the editor will look for the head file in you project.Especially for Dev-cpp editor.

    0 讨论(0)
  • 2020-12-09 23:02

    Try this: Settings->Compiler, click the tab Build options, select the checkbox

    Explicitly add currently compiling file's directory to compiler search dirs

    i did this and i works perfect now

    0 讨论(0)
  • 2020-12-09 23:07

    It looks like you're building a Windows application, rather than a console application. Therefore you need a WinMain function as the program entry point rather than a main.

    I'm not that familiar with CodeBlocks, but somewhere in the project setting there will be a setting that lets you specify the subsystem your program is running in. It's probably say "Windows", and one of the options should be "Console", so you can change it to that if you really want a console application. Judging by the fact your using cout I suspect a console application is what you want. If it is then you can leave main as your entry point.

    You can also opt for a console application when you create a new project. This screenshot and text should help.

    NOTE: I've just checked some more, and in the Project/target option you can go to the "Build targets" tab and see the subsystem you're building for. It's called "Type" on the tab, and one of the dropdown options will be "Console application".

    0 讨论(0)
  • 2020-12-09 23:08

    Try this: Settings->Compiler, click the tab Build options, select the checkbox

    Explicitly add currently compiling file's directory to compiler search dirs

    P.S.

    Next time when you create a new class, in the File policy section, make sure you select checkboxes

    • Add path to project

    • Header and implementation file shall be in same folder

    However, do NOT select

    Use relative path

    0 讨论(0)
提交回复
热议问题