2
votes

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
The symbol winMain is usually a symptom of console vs. windowing configuration of your project. Also, the w prefix usually indicates a character coding configuration issue: w meaning a wide character set.Thomas Matthews
Thanks for the hint, yes, makes sense that ‘w’ means a wide character set, this does not help me fix the problem though.FioKron
There are several occurrences of the unicode symbol U+2028 in your code, which is why it won't format correctly. Is this intended? (I don't know whether this is related to the errors. Someone else might clear this up.) Some of them are in front of # in the include lines. So this might explain the error message maybe? (# should always be the first character of the line.)user3072164
Sorry, '#' is the first character in the include lines in my code, IntelliSense is possibly playing up from what I have heard but I do not know.FioKron
There, I have now edited my post so that the include lines show up properly.FioKron

1 Answers

3
votes

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.