Error LNK2019: unresolved external symbol _wWinMain@16 referenced in function ___tmainCRTStartup

给你一囗甜甜゛ 提交于 2019-12-10 12:14:02

问题


I have started with DirectX 11 and get these compilation errors:

Error 1 error LNK2019: unresolved external symbol wWinMain@16 referenced in function __tmainCRTStartup

Error 2 error LNK1120: 1 unresolved externals(I figure that this error is because of the error just above this one)

I have searched around for fixes to this problem for quite a while, yet I cannot find any fixes to this problem on this site or any other sites via google.

I am using Visual Studio 2012 and c++ for this project. To make my testing project I created an empty project via New Project->Visual C++->Empty Project. I am using the standard compiler for this project.

This is my wWinMain header in my main.cpp file:

int wWinMain(HINSTANCE hInstance, HINSTANCE prevInstance,
 LPWSTR cmdLine, int cmdShow)

IntelliSense also keeps throwing up "4 IntelliSense: '#' not expected here" errors on some include lines at the start of the file, these lines: (EDIT: the errors keep disappearing and reappearing, repeatedly)

#include <Windows.h>
#include <memory>
#include "BlankDemo.h"
#include <tchar.h>

I put that in my post as I thought that this may be effected by, or have something to do with the error, it could just be the include files. BlankDemo.h is the header file for a test demo that just produces a blank DirectX 11 window.

All the code I have used is from a book on DirectX; as I am not used to DirectX yet, I have tried a number of fixes and none seem to get rid of this error, the fixes being:

Going to Properties->Configuration Properties->General->Character Set and changing that to "Use Unicode Character Set".

After changing the character set the error still remains.

Going to Properties->Linker->System and changing SubSystem to Windows (/SUBSYSTEM:WINDOWS).

I have also tried changing this to Console (/SUBSYSTEM:CONSOLE), neither of these changes seem to fix the problem.

I have also gone to Properties->Linker->Command Line and added /ENTRY:"wWinMainCRTStartup" to "Additional Options", this does not fix the problem either.

I have still left changes to the project as detailed above in the project. I have only put in the few lines of code as the errors seem to be about the code I have put in this post, also when I copy and paste the code, it does not seem to format correctly, but please tell me if you need to see more code.

EDIT: I have changed the function to int WINAPI __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE prevInstance,
 LPWSTR cmdLine, int cmdShow) Even using __stdcall or WINAPI in the function name does not work it seems. At least, in the way I have used them, please tell me if this is incorrect.


回答1:


Sorry guys, it seems that I made mistakes here, as in; I did not use Unicode to start off with, under Properties->Configuration Properties->General->Character Set. It seems that by using the Multi-Byte Character set to start off with, this confused Visual Studio 2012 into thinking that I was using the Multi-Byte Character set instead. This caused it to throw up the error, even though the entry point under Properties->Linker->Advanced was set to wWinMainCRTStartup. Makes sense, as the characters were not recognised properly.



来源:https://stackoverflow.com/questions/21243235/error-lnk2019-unresolved-external-symbol-wwinmain16-referenced-in-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!