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.
winMain
is usually a symptom of console vs. windowing configuration of your project. Also, thew
prefix usually indicates a character coding configuration issue:w
meaning a wide character set. – Thomas Matthews#
in the include lines. So this might explain the error message maybe? (#
should always be the first character of the line.) – user3072164