本文介绍了无法编译OpenGL Superbible 7th的示例(未解析的外部符号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm following the steps in HOWTOBUILD.txt. I have the necessary files for glfw built already. For the first time, the linker is complaining about glfw. After searching, it seems I need to link against gl3w see this link. I've generated the static libs for gl3w. Now, I've opened a new project and included the path to include, see the below picture.

对于链接器,我已针对glfw3dll.lib gl3w.lib opengl32.lib进行了链接,并包含了它们的路径.如果我是从第一章开始的示例,

For the linker, I've linked against glfw3dll.lib gl3w.lib opengl32.lib and included their path. If I run the sample from the first chapter,

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 Studio2013.我已跟踪链接器抱怨的其中一个函数(即sb6IsExtensionSupported()),下图显示了如何在sb7.h中调用该函数,而其主体实际上是在sb7.cpp中实现.

I'm using Visual Studio 2013. I've traced one of these functions that the linker is complaining about (i.e. sb6IsExtensionSupported()), the below picture shows how this function is being called in sb7.h while its body actually is implemented in sb7.cpp.

这真的正确吗?

推荐答案

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

I've solved the problem. It seems there is a static library that I have to link against and upgrade my Graphics card driver. Basically, this is I've done.

第一步:(构建GLFW)

如果您已经构建了库,则不必这样做,但是在构建示例时遇到的问题是,您需要正确地将路径设置为GLFW.为了节省您的时间,请同时构建GLFW.为此,

If you have the library already built, then you don't have to do so but the problem when you build the examples, you need to set the path to GLFW properly. To save your time, build GLFW as well. To do so,

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.libsb7_d.lib. _d表示调试模式.就我而言,这是导致问题的原因,因此,您需要针对此问题进行链接.打开新项目,将路径添加到sb7 includeglfw

Now in lib folder, there is sb7.lib and sb7_d.lib. _d means debug mode. In my case, this was causing the problem, therefore, you need to link against it. Open new project, add the path to sb7 include and glfw

C++->General-> Additional Include Directories

D:\CPP_Projects\VisualStudio\Modern OpenGL\sb7code-master\sb7code-master\include
D:\CPP_Libraries\glfw-3.1.1\glfw-3.1.1\include

对于链接器,

Linker->General->Additional Libraries Directories

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

Linker->Input->Additional Dependencies

sb7_d.lib
glfw3dll.lib
opengl32.lib
glu32.lib

结果是

非常重要的消息:

就我而言,图形卡支持OpenGL 4.1.根据readme.txt

In my case, the graphics cards supports OpenGL 4.1. According the readme.txt,

对于我来说,GLFW_OPENGL_CORE_PROFILE出现问题,因此我需要升级显卡驱动程序.我已经下载了该软件 opengl扩展查看器并下载了该软件向我展示了受支持的opengl版本.我的显示器自适应显示器是AMD Mobility Radeon HD5000.我已经访问了他们的网站并下载了最新的显示器驱动程序.实际上,我的图形卡现在支持OpenGL 4.4,这是快照

In my case, there was a problem with GLFW_OPENGL_CORE_PROFILE, therefore I needed to upgrade the graphics card driver. I've downloaded this software opengl extension viewer and it shows me the supported opengl version. My display adaptive is AMD Mobility Radeon HD 5000. I've visited their website and downloaded the latest driver for my display. Indeed, my graphics card now supports OpenGL 4.4 and this is a snapshot

您注意到有一个用于检查更新驱动程序的按钮.以我为例,它会将我定向到断开的链接,因此,您需要访问网站并检查自适应显示器的最新更新.谢谢你.

You notice there is a button for Check for update Drivers. In my case, it directs me to a broken link, therefore, you need to go the website and check for the latest update for your display adaptive. Thank you.

这篇关于无法编译OpenGL Superbible 7th的示例(未解析的外部符号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 12:44