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

I learn C ++ with Code :: Blocks, and every time I try to create a new class, I get an error:

undefined reference to `WinMain@16'

Here is the code I used:

Main class

#include "Lime.h"
#include <iostream>
using namespace std;
int main()
{
    Lime lime;
    return 0;
}

Lime Class (.ccp):

#include "Lime.h"
#include <iostream>
using namespace std;
Lime::Lime()
{
    cout<<"Hi!";
}

Lime Header (.h):

#ifndef LIME_H
#define LIME_H
class Lime
{
    public:
        Lime();
};
#endif

If someone knows how to fix this, please tell me!

+4
source share
10 answers

Try the following: SettingsCompiler, click the tab Build options, check the box

Explicitly add currently compiling a file directory to the compiler search directory

PS

The next time you create a new class, in the section, File policymake sure you select the checkboxes

  • Add project path

,

+9

, .

? , CodeBlocks . , - . .

? , , CodeBlocks header/cpp, , ( ). .

, , , Windows GUI , . , Bucky .

+8

, Windows, . WinMain , main.

CodeBlocks, - , , . , "Windows", "", , . , cout, , - , . , main .

. .

. , Project/target option " " , . "" , " ".

+2

"Project" --> "Build Options . . ."

"Linker Settings"

"Link libraries" "Add"
: mingw32;libSDL.a;libSDLmain.a
"Search directories" --> "Linker"

MinGW! !

+2

, OK. . !

, . / , .

0

... , , " ", "" , ( ).cbp ... , .h .cpp ... ... ..

0

, , , head. , #include "Burrito.h", head . Dev-cpp.

0

: - > , " ",

,

0

: undefined `WinMain @16 ' undefined ' class-name:: class-name() ' CodeBlocks

. .

. g++ ++ 11 ISO ++ [-std = ++ 11]
"" [F9]. , .

0

, "main.cpp" . , , , .

0

Source: https://habr.com/ru/post/1524856/


All Articles