• Register
0 votes
193 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

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 4 views
4 views
What is the difference between void main() and int main() in c++?
asked Oct 9 sikandar 2.4k points
0 votes
1 answer 22 views
22 views
Problem: I have recently started learning C language as currently lockdown is going on so I am learning C language with the help of available online tutorials. I have managed to write the binary search algorithm. If I try to compile my binary search algorithm then I am facing very ... +1, high);     else if(val == sorted[mid])         return mid; } Please guide me in fixing my above C code.
asked Aug 1 Raphael Pacheco 4.9k points
1 vote
1 answer 118 views
118 views
Problem : I am learning C. If I try to compile my below code then I often face an error message as shown below “Warning: control may reach end of non-void function [-wreturn-type]”. How can I fix my below code to avoid above error message? Below is my code which is ... (board[r][c - 1] == 0)         {             return true;         }     }     else     {         return false;     } }
asked Apr 27 stewart 4k points
1 vote
1 answer 18 views
18 views
Problem: I am exploring the c++ programming language nowadays. It’s really interesting to learn new things every day. I was trying to adopt the methods in c++ but struggling to return values from a void method. I actually want to know that if it is ... a return statement in a void method. Thanks for your co-operation in this learning process. I really appreciate your effort. Thanks again.
asked Mar 25 Gavin 15.3k points
1 vote
1 answer 14 views
14 views
Problem: I am trying to make a program that will convert the temperature from Celcius to Fahrenheit and vice-versa. The sample code is attached below: #include <iostream> using namespace std; void dialouge(); int c2f(); int f2c(); int c2f() { int c; int choice; ... reaches end of non-void function what does it mean? and if there is anything wrong that I haven't noticed, please point it out.
asked Mar 9 Gavin 15.3k points