C++ can';t编译OpenGL Superbible 7的示例(未解析的外部符号)

C++ can';t编译OpenGL Superbible 7的示例(未解析的外部符号),c++,windows,linker-errors,opengl-4,C++,Windows,Linker Errors,Opengl 4,我将按照HOWTOBUILD.txt中的步骤进行操作。我已经为glfw建立了必要的文件。链接器第一次抱怨glfw。搜索之后,我似乎需要链接gl3w。我已经为gl3w生成了静态lib。现在,我已经打开了一个新项目,并包含了include的路径,请参见下图 对于链接器,我已经链接了glfw3dl.lib gl3w.lib opengl32.lib,并包含了它们的路径。如果我运行第一章的样本 main.cpp #include "sb7.h" class my_application : pub

我将按照
HOWTOBUILD.txt
中的步骤进行操作。我已经为glfw建立了必要的文件。链接器第一次抱怨glfw。搜索之后,我似乎需要链接
gl3w
。我已经为
gl3w
生成了静态lib。现在,我已经打开了一个新项目,并包含了
include
的路径,请参见下图

对于链接器,我已经链接了
glfw3dl.lib gl3w.lib opengl32.lib
,并包含了它们的路径。如果我运行第一章的样本

main.cpp

#include "sb7.h"


class my_application : public sb7::application
{
    void render(double currentTime)
    {
        static const GLfloat red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, red);
    }
};


DECLARE_MAIN(my_application);
我得到链接器错误

1>main.obj : error LNK2019: unresolved external symbol "int __cdecl sb6IsExtensionSupported(char const *)" (?sb6IsExtensionSupported@@YAHPBD@Z) referenced in function "public: virtual void __thiscall sb7::application::run(class sb7::application *)" (?run@application@sb7@@UAEXPAV12@@Z)
1>main.obj : error LNK2019: unresolved external symbol "private: static void __stdcall sb7::application::debug_callback(unsigned int,unsigned int,unsigned int,unsigned int,int,char const *,void *)" (?debug_callback@application@sb7@@CGXIIIIHPBDPAX@Z) referenced in function "public: virtual void __thiscall sb7::application::run(class sb7::application *)" (?run@application@sb7@@UAEXPAV12@@Z)
1>main.obj : error LNK2001: unresolved external symbol "protected: static class sb7::application * sb7::application::app" (?app@application@sb7@@1PAV12@A)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
我正在使用Visual Studio 2013。我跟踪了链接器抱怨的其中一个函数(即
sb6IsExtensionSupported()
),下图显示了如何在
sb7.h
中调用此函数,而其主体实际上是在
sb7.cpp
中实现的


这真的正确吗?

我已经解决了这个问题。似乎有一个静态库,我必须链接并升级我的图形卡驱动程序。基本上,这是我做的

第一步:(建立GLFW)

如果已经构建了库,则不必这样做,但在构建示例时,需要正确设置GLFW的路径。为了节省时间,还可以构建GLFW。为此,

1- install cmake.
2- Open the command prompt and navigate to extern/glfw-3.0.4 (using cd command)
3- Type in command prompt: cmake -G "Visual Studio 12" 
4- Open GLFW.sln and build all ( do it for Debug and Release modes)
5- Copy `glfw-3.0.4/src/Debug/glfw3.lib` into the `lib` directory and rename it to glfw3_d.lib.
6- Copy `glf3-3.0.4/src/Release/glfw3.lib` into the `lib` directory but don't rename it.
第二步:(构建样本)

运行示例

1- Open the command prompt and navigate to "build" folder
2- Type in command prompt: cmake -G "Visual Studio 12" ..
3- Open superbible7.sln in build folder and build all. (do it for Debug and Release modes). 
现在在lib文件夹中有
sb7.lib
sb7_d.lib
<代码>\u d表示调试模式。在我的例子中,这是导致问题的原因,因此,您需要对其进行链接。打开新项目,将路径添加到
sb7 include
glfw

C++->General->Additional Include目录

D:\CPP_Projects\VisualStudio\Modern OpenGL\sb7code-master\sb7code-master\include
D:\CPP_Libraries\glfw-3.1.1\glfw-3.1.1\include
对于链接器

链接器->常规->附加库目录

D:\CPP_Libraries\glfw-3.1.1\glfw-3.1.1\install\src\Debug
D:\CPP_Projects\VisualStudio\Modern OpenGL\GLFW\OpenGLSuperBible_7th\OpenGLSuperBible\ChapterOne\Debug
sb7_d.lib
glfw3dll.lib
opengl32.lib
glu32.lib
链接器->输入->其他依赖项

D:\CPP_Libraries\glfw-3.1.1\glfw-3.1.1\install\src\Debug
D:\CPP_Projects\VisualStudio\Modern OpenGL\GLFW\OpenGLSuperBible_7th\OpenGLSuperBible\ChapterOne\Debug
sb7_d.lib
glfw3dll.lib
opengl32.lib
glu32.lib
结果是

非常重要的信息:

在我的例子中,图形卡支持OpenGL 4.1。根据
readme.txt

请注意:即使您可以为您的 您最喜欢的平台选择,您需要最新的OpenGL 4.x驱动程序才能运行 他们。请不要平移书本,因为您的计算机不支持 opengl4.x。谢谢

在我的例子中,
GLFW\u OPENGL\u CORE\u PROFILE
存在问题,因此我需要升级图形卡驱动程序。我已经下载了这个软件,它向我展示了受支持的opengl版本。我的显示器是AMD Mobility Radeon HD 5000。我已经访问了他们的网站,并下载了最新的显示器驱动程序。事实上,我的图形卡现在支持OpenGL 4.4,这是一个快照


您注意到有一个用于检查更新驱动程序的按钮。在我的情况下,它会将我指向一个断开的链接,因此,您需要访问该网站并检查显示的最新更新。多谢各位

为什么要为链接器使用这种路径?@AliaksiejMaroz因为它有sb7_d.lib和glfw3dl.lib您是如何找到glfw3dl.lib的?你单独下载过这个库吗?