LIBCMTD.lib(wcrt0.obj)LNK2019:未解析的外部符号_wmain在函数___tmainCRTStartup中引用未解析的externals freeGLUT.dll

时间:2012-06-16 20:10:32

标签: linker-errors visual-studio-debugging freeglut

我在使用freeGLUT开发的VS2010中使用了一个解决方案(不是我自己的),它是GLUT(OpenGL的Utility Toolkit)的开源和扩展替代品。程序在Release模式下编译并运行exe就好了,但是在尝试调试时,我得到以下错误:

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

错误2错误LNK1120:1个未解析的外部组件freeglut.dll freeglut

我下载并引用了所有lib和include文件,比如README文件告诉我:

Installation

Create a folder on your PC which is readable by all users, for example
“C:\Program Files\Common Files\MSVC\freeglut\” 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!

以下是链接器设置截图的链接,正如我现在所拥有的那样:http://imgur.com/a/SDwBv

2 个答案:

答案 0 :(得分:1)

属性 - &GT;链接器&GT;系统 - &GT; SubSytem

将Windows(/ SUBSYSTEM:WINDOWS)更改为控制台(/ SUBSYSTEM:CONSOLE)

答案 1 :(得分:0)

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

问:你是否按照说明选择了“Windows应用程序”?

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

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

如果您正在构建.dll,请将Visual Studio“target”更改为.dll和“Rebuild all”。

如果您正在构建.exe,请找到“主模块”并确保它包含在您的项目中。