LIBCMTD.lib(wcrt0.obj) LNK2019:未解析的外部符号_wmain函数中引用___tmainCR



我正在使用VS2010中使用的解决方案(不是我自己的解决方案),该解决方案使用freeGLUT开发,freeGLUT是GLUT(OpenGL的实用程序工具包)的开源和扩展替代品。该程序在发布模式下编译并运行exe很好,但是在尝试调试时,我收到以下错误:

错误

1 错误 LNK2019:函数 __tmainCRTStartup LIBCMTD.lib(wcrt0.obj) freeglut 中引用的未解析的外部符号 wmain

错误

2 错误 LNK1120:1 个未解决的外部自由过剩.dll自由过剩

我下载并引用了所有库,并包含像自述文件告诉我这样的文件:

Installation
Create a folder on your PC which is readable by all users, for example
“C:Program FilesCommon FilesMSVCfreeglut” on a typical Windows system. Copy
the “lib” and “include” folders from this zip archive to that location.
The appropriate freeglut DLL can either be placed in the same folder as your
application, or can be installed in a system-wide folder which appears in your
%PATH% environment variable. Be careful not to mix the 32 bit DLL up with the 64
bit DLL, as they are not interchangeable.

Compiling 32 bit Applications
To create a 32 bit freeglut application, create a new Win32 C++ project in MSVC.
From the “Win32 Application Wizard”, choose a “Windows application”, check the
“Empty project” box, and submit.
You’ll now need to configure the compiler and linker settings. Open up the
project properties, and select “All Configurations” (this is necessary to ensure
our changes are applied for both debug and release builds). Open up the
“general” section under “C/C++”, and configure the “include” folder you created
above as an “Additional Include Directory”. If you have more than one GLUT
package which contains a “glut.h” file, it’s important to ensure that the
freeglut include folder appears above all other GLUT include folders.
Now open up the “general” section under “Linker”, and configure the “lib”
folder you created above as an “Additional Library Directory”.

A freeglut
application depends on the import libraries “freeglut.lib” and “opengl32.lib”,
which can be configured under the “Input” section.

However, it shouldn’t be
necessary to explicitly state these dependencies, since the freeglut headers
handle this for you. Now open the “Advanced” section, and enter “mainCRTStartup”
as the “Entry Point” for your application. This is necessary because GLUT
applications use “main” as the application entry point, not “WinMain”—without it
you’ll get an undefined reference when you try to link your application.
That’s all of your project properties configured, so you can now add source
files to your project and build the application. If you want your application to
be compatible with GLUT, you should “#include <GL/glut.h>”. If you want to use
freeglut specific extensions, you should “#include <GL/freeglut.h>” instead.
Don’t forget to either include the freeglut DLL when distributing applications,
or provide your users with some method of obtaining it if they don’t already
have it!

以下是我现在拥有的链接器设置屏幕截图的链接:https://i.stack.imgur.com/O67nK.jpg

Properties->

Linker->System->SubSytem

将 Windows (/SUBSYSTEM:

WINDOWS) 更改为 Console (/SUBSYSTEM:CONSOLE)

"

wmain"是图形Windows.exe的主要入口点。

问:您是否像说明中所说的那样选择了"Windows 应用程序"?

问:您是在构建一个.exe(整个程序),还是只是一个.dll?

链接器认为您正在尝试构建一个.exe,并且它想要一个"主程序"(带有"wmain()")。

如果要构建.dll,请将Visual Studio的"目标"更改为.dll并"全部重新生成"。

如果要构建.exe,请找到"主模块"并确保它包含在项目中。

最新更新