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 beint 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
C++: Modifying Array Via Function
How to Convert String to Ip Address and Vice Versa
Why Can Templates Only Be Implemented in the Header File
Templated Check For the Existence of a Class Member Function
What Are the Main Purposes of Using Std::Forward and Which Problems It Solves
Why Is Volatile Not Considered Useful in Multithreaded C or C++ Programming
How to Remove Code Duplication Between Similar Const and Non-Const Member Functions
How to Print Function Pointers With Cout
How to Cast Const Uint8_T* to Char*
Checking If All Elements of a Vector Are Equal in C++
Why Is Iostream::Eof Inside a Loop Condition (I.E. 'While (!Stream.Eof())') Considered Wrong
When Should Static_Cast, Dynamic_Cast, Const_Cast, and Reinterpret_Cast Be Used
What Does Int Argc, Char *Argv[] Mean
Array Size At Run Time Without Dynamic Allocation Is Allowed