Undefined Reference to 'Winmain@16'

undefined reference to WinMain@16 (codeblocks)

When there's no project, Code::Blocks only compiles and links the current file. That file, from your picture, is secrypt.cpp, which does not have a main function. In order to compile and link both source files, you'll need to do it manually or add them to the same project.

Contrary to what others are saying, using a Windows subsystem with main will still work, but there will be no console window.

Your other attempt, compiling and linking just trial.cpp, never links secrypt.cpp. This would normally result in an undefined reference to jRegister(), but you've declared the function inside main instead of calling it. Change main to:

int main()
{
jRegister();

return 0;
}

why my code is showing error undefined reference to `WinMain@16'?

Do changes in the project settings if you are using Visual Studio.

Go to the Project menu, your project properties, Linker, System and change the SubSystem option from Windows (/SUBSYSTEM:WINDOWS) to Console (/SUBSYSTEM:CONSOLE) via the drop-down list.

Do changes in the project/target options if you're using Code::Blocks.

Goto Build Targets, the default setting for Type: GUI application - is incorrect for your project, change it to Console application via the drop-down list.

Undefined reference to `WinMain@16' error when compile with gcc

You do not define the main function, the code generated by flex and bison do not define the main function, you have to define it by yourself else the program do not have an entry point.

You have problems in your definitions :

  • in tt.y {printf("f\n", $1);} have a format not compatible with an argument, must be ``{printf("%f\n", $1);}` ?
  • in tt.y declare yyerror in the header with the declaration of yylex
  • in calc.l int yywrap() {return -1} must be int yywrap() {return -1;}

The minimal main definition is :

int main()
{
yyparse();
return 0;
}

you can put it with the definition of yyerror in tt.y

GCC C++ linking error : Undefined reference to 'WinMain@16' [duplicate]

Rename your main to be WinMain with the following parameters

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCmdLine, INT nCmdShow)
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Quit();

return 0;
}

Most of those parameters will require #include <windows.h> If that header is not available, then declare as:

int __stdcall WinMain(void*, void*, char*, int)


Related Topics



Leave a reply



Submit