Cro*_*oCo 6 c++ windows linker-errors opengl-4
我正在按照步骤进行操作HOWTOBUILD.txt.我已经为glfw构建了必要的文件.链接器第一次抱怨glfw.搜索后,似乎我需要链接反对gl3w 看到这个链接.我为它生成了静态库gl3w.现在,我已经开了一个新项目并包含了路径include,见下图.
对于链接器,我已经链接glfw3dll.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);
Run Code Online (Sandbox Code Playgroud)
我收到链接器错误.
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
Run Code Online (Sandbox Code Playgroud)
我正在使用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.
Run Code Online (Sandbox Code Playgroud)
第二步:(建筑样品)
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).
Run Code Online (Sandbox Code Playgroud)
运行示例
现在在lib文件夹中,有sb7.lib和sb7_d.lib._d调试模式.在我的情况下,这导致了问题,因此,您需要链接它.打开新项目,添加路径sb7 include和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
Run Code Online (Sandbox Code Playgroud)
对于链接器,
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
Run Code Online (Sandbox Code Playgroud)
Linker->Input->Additional Dependencies
sb7_d.lib
glfw3dll.lib
opengl32.lib
glu32.lib
Run Code Online (Sandbox Code Playgroud)
结果是
非常重要的消息:
就我而言,显卡支持OpenGL 4.1.根据readme.txt,
请注意:即使您可以为您最喜欢的选择平台构建源,您也需要最近的OpenGL 4.x驱动程序来运行它们.请不要把书放在书本上,因为你的计算机不支持OpenGL 4.x. 谢谢
在我的情况下,有一个问题GLFW_OPENGL_CORE_PROFILE,因此我需要升级显卡驱动程序.我已经下载了这个软件opengl扩展查看器,它向我展示了支持的opengl版本.我的显示器自适应是AMD Mobility Radeon HD 5000.我访问了他们的网站,并为我的显示器下载了最新的驱动程序.实际上,我的显卡现在支持OpenGL 4.4,这是一个快照
您注意到有一个用于检查更新驱动程序的按钮.在我的情况下,它会指示我链接断开,因此,您需要访问网站并检查显示适应性的最新更新.谢谢.
| 归档时间: |
|
| 查看次数: |
3193 次 |
| 最近记录: |