0

我正在尝试编译这个利用 GLUT32 库的 C++ 程序。

现在我收到以下错误:

错误 1 ​​错误 LNK2001:无法解析的外部符号 _gluPerspective@32 Camera.obj soundCube 错误 2 错误 LNK2001:无法解析的外部符号 _gluLookAt@72 Camera.obj soundCube 错误 3 错误 LNK2001:无法解析的外部符号 __imp__glMaterialfv@12 GLWindow.obj soundCube 错误 4 错误 LNK2001:无法解析的外部符号 __imp__glClear@4 GLWindow.obj soundCube 错误 5 错误 LNK2001:无法解析的外部符号 __imp__glClearColor@16 GLWindow.obj soundCube 错误 6 错误 LNK2001:无法解析的外部符号 __imp__glMaterialf@12 GLWindow.obj soundCube 错误 7 错误 LNK2001:无法解析的外部符号 __imp__glEnd@ 0 GLWindow.obj soundCube 错误 8 错误 LNK2001:无法解析的外部符号 __imp__glRasterPos2f@8 GLWindow.obj soundCube 错误 9 错误 LNK2001:无法解析的外部符号 __imp__timeGetTime@0 GLWindow.obj soundCube 错误 10 错误 LNK2001:无法解析的外部符号 __imp__glDisable@4 GLWindow.obj soundCube 错误 11 错误 LNK2001:无法解析的外部符号 __imp__glBegin@4 GLWindow.obj soundCube 错误 12 错误 LNK2001:无法解析的外部符号 __imp__glColor4f@ 16 GLWindow.obj soundCube 错误 13 错误 LNK2001:无法解析的外部符号 __imp__glPopMatrix@0 GLWindow.obj soundCube 错误 14 错误 LNK2001:无法解析的外部符号 __imp__glPushMatrix@0 GLWindow.obj soundCube 错误 15 错误 LNK2001:无法解析的外部符号 __imp__glRotatef@16 GLWindow.obj soundCube错误 16 错误 LNK2001:无法解析的外部符号 __imp__glBlendFunc@8obj soundCube 错误 10 错误 LNK2001:无法解析的外部符号 __imp__glDisable@4 GLWindow.obj soundCube 错误 11 错误 LNK2001:无法解析的外部符号 __imp__glBegin@4 GLWindow.obj soundCube 错误 12 错误 LNK2001:无法解析的外部符号 __imp__glColor4f@16 GLWindow.obj soundCube 错误 13 错误LNK2001:无法解析的外部符号 __imp__glPopMatrix@0 GLWindow.obj soundCube 错误 14 错误 LNK2001:无法解析的外部符号 __imp__glPushMatrix@0 GLWindow.obj soundCube 错误 15 错误 LNK2001:无法解析的外部符号 __imp__glRotatef@16 GLWindow.obj soundCube 错误 16 错误 LNK2001:无法解析的外部符号__imp__glBlendFunc@8obj soundCube 错误 10 错误 LNK2001:无法解析的外部符号 __imp__glDisable@4 GLWindow.obj soundCube 错误 11 错误 LNK2001:无法解析的外部符号 __imp__glBegin@4 GLWindow.obj soundCube 错误 12 错误 LNK2001:无法解析的外部符号 __imp__glColor4f@16 GLWindow.obj soundCube 错误 13 错误LNK2001:无法解析的外部符号 __imp__glPopMatrix@0 GLWindow.obj soundCube 错误 14 错误 LNK2001:无法解析的外部符号 __imp__glPushMatrix@0 GLWindow.obj soundCube 错误 15 错误 LNK2001:无法解析的外部符号 __imp__glRotatef@16 GLWindow.obj soundCube 错误 16 错误 LNK2001:无法解析的外部符号__imp__glBlendFunc@8无法解析的外部符号 __imp__glBegin@4 GLWindow.obj soundCube 错误 12 错误 LNK2001:无法解析的外部符号 __imp__glColor4f@16 GLWindow.obj soundCube 错误 13 错误 LNK2001:无法解析的外部符号 __imp__glPopMatrix@0 GLWindow.obj soundCube 错误 14 错误 LNK2001:无法解析的外部符号 __imp__glPushMatrix@ 0 GLWindow.obj soundCube 错误 15 错误 LNK2001:无法解析的外部符号 __imp__glRotatef@16 GLWindow.obj soundCube 错误 16 错误 LNK2001:无法解析的外部符号 __imp__glBlendFunc@8无法解析的外部符号 __imp__glBegin@4 GLWindow.obj soundCube 错误 12 错误 LNK2001:无法解析的外部符号 __imp__glColor4f@16 GLWindow.obj soundCube 错误 13 错误 LNK2001:无法解析的外部符号 __imp__glPopMatrix@0 GLWindow.obj soundCube 错误 14 错误 LNK2001:无法解析的外部符号 __imp__glPushMatrix@ 0 GLWindow.obj soundCube 错误 15 错误 LNK2001:无法解析的外部符号 __imp__glRotatef@16 GLWindow.obj soundCube 错误 16 错误 LNK2001:无法解析的外部符号 __imp__glBlendFunc@8无法解析的外部符号 __imp__glPushMatrix@0 GLWindow.obj soundCube 错误 15 错误 LNK2001:无法解析的外部符号 __imp__glRotatef@16 GLWindow.obj soundCube 错误 16 错误 LNK2001:无法解析的外部符号 __imp__glBlendFunc@8无法解析的外部符号 __imp__glPushMatrix@0 GLWindow.obj soundCube 错误 15 错误 LNK2001:无法解析的外部符号 __imp__glRotatef@16 GLWindow.obj soundCube 错误 16 错误 LNK2001:无法解析的外部符号 __imp__glBlendFunc@8

...

错误 56 致命错误 LNK1120:55 个未解析的外部 C:\Users\Simucal\Documents\Downloads\SoundCubeSrc soundCube

我在 C++ 方面没有那么有经验,但我尝试正确设置 GLUT,以便该项目可以链接到它。

我为Nate Robin 的页面下载了 GLUT32 库。

然后我将以下文件放入:

  • glut.h - C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl
  • glut32.lib - C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
  • glut.dll - C:\Windows\System32

我还选择了项目 -> 属性 -> 链接器 -> 附加依赖项 -> 添加了“glut32.lib”

如果有人想看看我正在处理什么项目,那就在这里

为了解决这些错误,我遗漏了哪些步骤或做错了什么?

4

2 回答 2

4

未解析的符号来自 GL 和 GLU 库。您还需要为它们添加链接库。

于 2010-02-07T19:09:51.147 回答
1

在我看来,您正在混合使用静态和动态链接选项。我正在下载你的项目进行调查,但你在做什么类型的编译?

我没有在项目中看到对 glut .lib 文件的引用...

我添加了库参考和 LIB/INCLUDE 路径:

diff --git a/soundCube/soundCube.vcproj b/soundCube/soundCube.vcproj
index 62e04c1..b71eb20 100644
--- a/soundCube/soundCube.vcproj
+++ b/soundCube/soundCube.vcproj
@@ -41,6 +41,7 @@
            <Tool
                Name="VCCLCompilerTool"
                Optimization="0"
+               AdditionalIncludeDirectories="d:\temp\glut"
                PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
                MinimalRebuild="true"
                BasicRuntimeChecks="3"
@@ -60,7 +61,9 @@
            />
            <Tool
                Name="VCLinkerTool"
+               AdditionalDependencies="glut32.lib"
                LinkIncremental="2"
+               AdditionalLibraryDirectories="d:\temp\glut\GL"
                GenerateDebugInformation="true"
                SubSystem="1"
                TargetMachine="1"
@@ -114,6 +117,7 @@
                Name="VCCLCompilerTool"
                Optimization="2"
                EnableIntrinsicFunctions="true"
+               AdditionalIncludeDirectories="d:\temp\glut"
                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
                RuntimeLibrary="0"
                EnableFunctionLevelLinking="true"
@@ -132,7 +136,9 @@
            />
            <Tool
                Name="VCLinkerTool"
+               AdditionalDependencies="glut32.lib"
                LinkIncremental="1"
+               AdditionalLibraryDirectories="d:\temp\glut\GL"
                GenerateDebugInformation="true"
                SubSystem="1"
                OptimizeReferences="2"
于 2010-02-07T18:47:21.167 回答