• Register
0 votes
449 views

Problem :

I am facing below error:

Severity Code Description Project File Line Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl imyNVoke_main(void)" (?imyNVoke_main@@YAHXZ) Severity Code Description Project File Line Error LNK1120 1 unresolved externals

Following is my code:

   #include "windows.h"
    #include "tchar.h"
    #include "d3d9.h"
    #pragma comment(lib, "d3d9.lib")
LPDIRECT3D9 pDirect3D=NULL; 
LPDIRECT3DDEVICE9 pDirect3DDevice=NULL; 
const int mysegment = 50;
const int myNV = mysegment*13;
struct CUSTOMVERTEX
{
   float x, y, z, rhv;
   DWORD color;
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
LPDIRECT3DVERTEXBUFFER9 pVertexBuffer=NULL; 
HRESULT InitialDirect3D(HWND hvnd)
{
   if((pDirect3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL)
      return E_FAIL;
   D3DDISPLAYMODE Display;
   if(FAILED(pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &Display)))
      return E_FAIL;
   D3DPRESENT_PARAMETERS Direct3DParameter;
   ZeroMemory(&Direct3DParameter, sizeof Direct3DParameter);
   Direct3DParameter.Windowed=TRUE;
   Direct3DParameter.SwapEffect=D3DSWAPEFFECT_DISCARD;
   Direct3DParameter.BackBufferFormat=Display.Format;
   if(FAILED(pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hvnd,
                                     D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                     &Direct3DParameter, &pDirect3DDevice)))
      return E_FAIL;
   return S_OK;
}
HRE
6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I have read your problem statement. I have understood the question.

I had also faced the same error in the recent past this is the rare case, but you can also face this error if you are trying to build the MFC application with CMake.

If that is the case, then you need to add the following definitions:

ADD_DEFINITIONS(-D_AFXDLL) SET(CMAKE_MFC_FLAG 2) # or 1 if you are looking for the static library

And if you are compiling with unicode, then the following properties also need to be added:

set_target_properties(MyApp PROPERTIES COMPILE_DEFINITIONS _AFXDLL,_UNICODE,UNICODE,_BIND_TO_CURRENT_CRT_VERSION,_BIND_TO_CURRENT_MFC_VERSION LINK_FLAGS "/ENTRY:\"wWinMainCRTStartup\"" )

 

 And your issue will be resolved

9 7 4
38,600 points

Related questions

0 votes
1 answer 73 views
73 views
Been getting the following error when trying to compile my code: error LNK2019: unresolved external symbol "public: void __thiscall Agent::printSelf(void)" (?printSelf@Agent@@QAEXXZ) referenced in function "public: void __thiscall World::processMouse(int,int,int,int)" (? ... on this code in a long time, so im not sure what has changed to cause this. Anyone see anything wrong?
asked Oct 30, 2020 psandprop 2.4k points
0 votes
1 answer 4 views
4 views
Problem: Anyone know about this then please answer me. I really suffered from this problem in my pc. Anyone help me out?
asked Apr 3 niyatiry 3.2k points
0 votes
2 answers 4 views
4 views
Problem: Can anyone help me out? I have no idea what I have to do on this, anyone know then please answer me.
asked Apr 1 niyatiry 3.2k points
1 vote
1 answer 1 view
1 view
Problem: Can anyone tell me the solution of this problem? Error lnk2019: unresolved external symbol "public: __thiscall
asked 5 days ago MUHAMMAD MUNEEB 83k points
0 votes
1 answer 3 views
3 views
problem: I am stuck in a problem of "_main", referenced from: implicit entry/start for main executable . please help ?
asked Apr 7 ashik 12.9k points
0 votes
1 answer 21 views
21 views
Problem: Why do we use int main in C++? How does a main function in C++ differ from main in C? Why void main is wrong? How to know the exit status of your program. That's the reason why you have the int main() -- you return your exit status. It's wrong because this is not what the C++ Standard specifies as a legal main . Nobody cares about what the other languages specify?
asked Dec 12, 2020 Mashhoodch 13k points
0 votes
1 answer 23 views
23 views
What is the difference between void main() and int main() in c++?
asked Oct 9, 2020 sikandar 2.4k points
0 votes
1 answer 2 views
2 views
Problem: I need help in resolving this problem: int main vs void main c++
asked 6 days ago rakib1 51.5k points
0 votes
1 answer 2 views
2 views
Question: I run the following C codes and got a warning: control reaches end of non-void function int main(void) {} Any suggestions?
asked 6 days ago Atik03 10.1k points
0 votes
1 answer 2 views
2 views
Problem : Why a warning of "control reaches end of non-void function" for the main function?
asked 6 days ago padma1 22.4k points