Sunday, 26 March 2017

c++ - Error: Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup




How do I resolve this error:



Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup 


I also define all the functions inside cai.cpp. However I did not upload it due to too many lines of codes. I do include the .h file into cai.cpp. I am confused as to what this error is asking.



main.cpp file




#include "cai.h"

int main()
{
CAI test;
test.StartTest();

}



cai.h file



class CAI
{
public:

void StartTest();
bool AskRandomMultiplicationQuestion();
bool AskRandomDivisioQuestion();



private:
void PrintRandomGoodJob();
void PrintRandomEncouragementMessage();
int ChooseRandomNumber();
void PrintTestSummary(int, int, int);

};


Answer



Set your sub system to console instead of windows, or add the winmain function as your entry point.



See: http://msdn.microsoft.com/en-us/library/fcc1zstk.aspx



And:



difference between Console (/SUBSYSTEM:CONSOLE) and Windows (/SUBSYSTEM:WINDOWS)


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...