0

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

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

错误 2 error LNK1120: 1 unresolved externals freeglut.dll freeglut

我下载并引用了所有的 lib 和包含文件,例如 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

4

2 回答 2

1

属性->链接器->系统->子系统

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

于 2015-02-16T13:23:27.753 回答
0

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

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

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

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

如果您正在构建 .dll,请将您的 Visual Studio“目标”更改为 .dll 并“全部重建”。

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

于 2012-06-16T20:36:07.337 回答