错误LNK2019:未解析的外部符号_wWinMain @ 16在函数___tmainCRTStartup中引用 [英] Error LNK2019: unresolved external symbol _wWinMain@16 referenced in function ___tmainCRTStartup

查看:466
本文介绍了错误LNK2019:未解析的外部符号_wWinMain @ 16在函数___tmainCRTStartup中引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用DirectX 11并得到这些编译错误:

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

错误1错误LNK2019:未解析的外部符号 wWinMain @ 16在函数_ em> _tmainCRTStartup

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

错误2错误LNK1120:1未解决的外部(我认为此错误是因为错误刚好在此之上)

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.

我使用Visual Studio 2012和c ++为这个项目。为了做我的测试项目,我通过New Project-> Visual C ++ - > Empty Project创建了一个空项目。
我使用标准的编译器为这个项目。

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.

这是我的wWinMain头在我的main.cpp文件:

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

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

IntelliSense还会继续呕吐4 IntelliSense:'#'不期望在这里错误在一些包含行在文件的开头,这些行:(编辑:错误继续消失,并重复出现)

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

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

我把它放在我的帖子中,因为我认为这可能会受到与错误,它可以只是包含文件。 BlankDemo.h是一个测试演示的头文件,只是生成一个空白的DirectX 11窗口。

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.

我使用的所有代码都来自一本关于DirectX的书;因为我不习惯DirectX,我已经尝试了一些修复,没有人似乎摆脱这个错误,修复是:

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:

转到属性 - >配置属性 - >通用 - >字符集,并将其更改为使用Unicode字符集。

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.

转到属性 - >链接器 - >系统并将子系统更改为Windows(/ SUBSYSTEM:WINDOWS)。

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

我也尝试过改变这个控制台(/ SUBSYSTEM:CONSOLE),这些更改似乎没有解决这个问题。

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

我也去了属性 - >链接器 - >命令行并添加/ ENTRY:wWinMainCRTStartup到附加选项,这也不能解决问题。

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.

编辑:我已经将函数更改为 int WINAPI __stdcall wWinMain(HINSTANCE hInstance,HINSTANCE prevInstance,LPWSTR cmdLine,int cmdShow )
即使在函数名中使用 __ stdcall WINAPI 它似乎。至少,在我使用它们的方式,请告诉我,如果这是不正确的。

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.

推荐答案

对不起,似乎我在这里犯了错误,我没有使用Unicode开始,在属性 - >配置属性 - >通用 - >字符集。看来,通过使用多字节字符集开始,这让Visual Studio 2012的思想,我使用多字节字符集而不是。这导致它抛出错误,即使属性 - >链接器 - >高级下的入口点设置为wWinMainCRTStartup。有意义,因为字符无法正确识别。

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.

这篇关于错误LNK2019:未解析的外部符号_wWinMain @ 16在函数___tmainCRTStartup中引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆