Cannot compile OpenGL Superbible 7th samples (unresolved external symbol)

I follow the steps in HOWTOBUILD.txt . I have the necessary files to create glfw. For the first time, the linker complains about glfw. After searching, it seems I need to link with gl3w see this link . I created static libraries for gl3w . Now I opened a new project and included the path to include , see the figure below.

enter image description here

For the linker, I linked to glfw3dll.lib gl3w.lib opengl32.lib and included their path. If I ran 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); 

I get linker errors.

 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 

I am using Visual Studio 2013. I traced one of these functions that the linker complains about (ie sb6IsExtensionSupported() ). The figure below shows how this function is called in sb7.h , while its body is actually implemented in sb7.cpp .

enter image description here

Is this really right?

+4
source share
1 answer

I solved the problem. There seems to be a static library with which I need to link and update the video card driver. In principle, I did it.

Step One: (Building GLFW)

If you already have the library installed, you do not need to do this, but the problem is when building the examples, you need to set the path to GLFW correctly. To save your time, create GLFW. For this

 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. 

Step Two: (Building Samples)

 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). 

Execution examples

Now in the lib folder there are sb7.lib and sb7_d.lib . _d means debug mode. In my case, this was causing the problem, so you need to link it. Open a 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 

For linker

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 

Result

enter image description here

VERY IMPORTANT MESSAGE:

In my case, graphics cards support OpenGL 4.1. According to readme.txt ,

Please Note: EVEN IF YOU CAN CREATE SOURCES FOR YOUR FAVORITE SELECTION PLATFORM, YOU NEED THE LATEST OpenGL 4.x DRIVERS TO WORK THEM. PLEASE DO NOT PLAN A BOOK BECAUSE THE COMPUTER DOES NOT SUPPORT OpenGL 4.x. THANKS

In my case, there was a problem with GLFW_OPENGL_CORE_PROFILE , so I needed to update the video driver. I downloaded this opengl extension viewer software and it shows me a supported version of opengl. My responsive display is the AMD Mobility Radeon HD 5000. I 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

enter image description here

You noticed that there is a button Check for driver updates. In my case, this directs me to a broken link, so you need to go to the site and check the latest adaptive display update. Thanks.

+4
source

All Articles