0
votes

The errors I'm going through is :

  1. Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) C:\Users\kaise\source\repos\workshop\workshop\MSVCRTD.lib(exe_main.obj)

  2. Error LNK1120 1 unresolved externals workshop C:\Users\kaise\source\repos\workshop\Debug\workshop.exe

I been working with this errors for 2 weeks

#include<iostream>
#include<cstdio>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdlib>
#include<conio.h>
#include<windows.h>
#include<mysql.h>
#include<tchar.h>

using namespace std;

// Global Variable
int qstate;
MYSQL* conn;
MYSQL_ROW row;
MYSQL_RES* res;
// Global Variable End

class db_response
{
public:
    static void ConnectionFunction()
    {
        conn = mysql_init(0);
        if (conn)
        {
            cout << "Database Connected" << endl;
            cout << "Press any key to continue..." << endl;
            
            system("cls");
        }
        else
            cout << "Failed To Connect!" << mysql_errno(conn) << endl;
        conn = mysql_real_connect(conn, "localhost", "root", "", "medic", 3306, NULL, 0);
        if (conn)
        {
            cout << "Database Connected To MySql" << conn << endl;
            cout << "Press any key to continue..." << endl;
           
            system("cls");
        }
        else
            cout << "Failed To Connect!" << mysql_errno(conn) << endl;
    }
};
1
Are you aware that a C++ program has to define one function main()? If you try to compile and link your exposed code as is, the compiler will notice the lack of it. FYI: Main functionScheff's Cat

1 Answers

0
votes

This error lnk2019 is generally due to the lack of entry function when the program is running.

In general: If it is a Windows program, the WinMain is the entry function; If it is a Console program, the main is the entry function.

So, you could check whether the settings in the Propetties->Linker->System are consistent with your expectations.

Of course, if the program is dll or lib, you need to set dll or lib in Properties->General->Configuration Type.

enter image description here