How to set up OpenGL

Hi, I got the OpenGL superbible, but I can't get the first code they give to run. Here it is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  // Include the "sb6.h" header file
#include "sb6.h"
// Derive my _ application from sb6::application
class my_application : public sb6::application
{
public:
// Our rendering function
void render(double currentTime)
{
// Simply clear the window with red
static const GLfloat red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
glClearBufferfv(GL_COLOR, 0, red);
}
};
// Our one and only instance of DECLARE_MAIN
DECLARE _ MAIN(my_application);


My errors are

1
2
3
4
5
6
7
Error	1	error C1083: Cannot open include file: 'sb6.h': No such file or directory	c:\users\saam2_000\documents\visual studio 2013\projects\project2\project2\source.cpp	2	1	Project2
	2	IntelliSense: cannot open source file "sb6.h"	c:\Users\saam2_000\Documents\Visual Studio 2013\Projects\Project2\Project2\Source.cpp	2	1	Project2
	3	IntelliSense: name followed by '::' must be a class or namespace name	c:\Users\saam2_000\Documents\Visual Studio 2013\Projects\Project2\Project2\Source.cpp	4	31	Project2
	4	IntelliSense: identifier "GLfloat" is undefined	c:\Users\saam2_000\Documents\Visual Studio 2013\Projects\Project2\Project2\Source.cpp	11	16	Project2
	5	IntelliSense: identifier "glClearBufferfv" is undefined	c:\Users\saam2_000\Documents\Visual Studio 2013\Projects\Project2\Project2\Source.cpp	12	3	Project2
	6	IntelliSense: identifier "GL_COLOR" is undefined	c:\Users\saam2_000\Documents\Visual Studio 2013\Projects\Project2\Project2\Source.cpp	12	19	Project2
	7	IntelliSense: explicit type is missing ('int' assumed)	c:\Users\saam2_000\Documents\Visual Studio 2013\Projects\Project2\Project2\Source.cpp	16	1	Project2


and I putted the header file in my project
Last edited on
From the output you're getting, it looks like you're using Visual Studio. Putting an existing file in your project in Visual Studio only creates a link to that project on the file system - it doesn't copy the file anywhere. As a result, you are trying to #include "sb6.h", but "sb6.h" doesn't exist in any directory this project knows about.

You have two options.
1. Delete the sb6.h link you added to your VS project, find sb6.h on your file system and manually copy it into the appropriate directory, and then re-add a link to the one you manually copied.
2. THE BETTER OPTION: Add the directory where sb6.h is to your C++ Include Directories in your project settings. (https://msdn.microsoft.com/en-us/library/ee855621.aspx)
move the sb6.h file into your project folder
Last edited on
Ok now I managed to get the include and lib folders linked, but I get some errors. This is what I get now when I try to run the code in my first post:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Error	1	error LNK2019: unresolved external symbol _gl3wInit referenced in function "public: virtual void __thiscall sb6::application::run(class sb6::application *)" (?run@application@sb6@@UAEXPAV12@@Z)	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	2	error LNK2019: unresolved external symbol _gl3wIsSupported referenced in function "public: virtual void __thiscall sb6::application::run(class sb6::application *)" (?run@application@sb6@@UAEXPAV12@@Z)	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	3	error LNK2019: unresolved external symbol "int __cdecl sb6IsExtensionSupported(char const *)" (?sb6IsExtensionSupported@@YAHPBD@Z) referenced in function "public: virtual void __thiscall sb6::application::run(class sb6::application *)" (?run@application@sb6@@UAEXPAV12@@Z)	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	4	error LNK2001: unresolved external symbol _gl3wEnable	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	5	error LNK2001: unresolved external symbol _gl3wGetString	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	6	error LNK2001: unresolved external symbol _gl3wClearBufferfv	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	7	error LNK2001: unresolved external symbol _gl3wDebugMessageCallbackARB	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	8	error LNK2001: unresolved external symbol _gl3wDebugMessageCallback	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	9	error LNK2001: unresolved external symbol "protected: static class sb6::application * sb6::application::app" (?app@application@sb6@@1PAV12@A)	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\main.obj	testopengl3
Error	10	error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _glfwOpenWindow	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(window.obj)	testopengl3
Error	11	error LNK2001: unresolved external symbol __imp__glClear@4	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	12	error LNK2019: unresolved external symbol __imp__glGetIntegerv@8 referenced in function _glfwExtensionSupported	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(glext.obj)	testopengl3
Error	13	error LNK2001: unresolved external symbol __imp__glGetIntegerv@8	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	14	error LNK2019: unresolved external symbol __imp__glGetString@4 referenced in function _glfwExtensionSupported	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(glext.obj)	testopengl3
Error	15	error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function _createContext	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	16	error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function _destroyWindow	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	17	error LNK2019: unresolved external symbol __imp__wglGetProcAddress@4 referenced in function _initWGLExtensions	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	18	error LNK2001: unresolved external symbol __imp__wglGetProcAddress@4	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_glext.obj)	testopengl3
Error	19	error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function _createWindow	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	20	error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function __glfwPlatformSetWindowSize	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	21	error LNK2019: unresolved external symbol __imp__glGetFloatv@8 referenced in function __glfwPlatformSetWindowSize	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\testopengl3\GLFW.lib(win32_window.obj)	testopengl3
Error	22	error LNK1120: 18 unresolved externals	C:\Users\saam2_000\Documents\Programmation\C++\Programmes\testopengl3\Debug\testopengl3.exe	testopengl3


I googled this and somebody said that I had to link gl3w, so this http://www.jakerobbins.net/20140901/compiling-gl3w-in-windows/ is what I tried and this is what I get:

1
2
3
Error	1	error MSB3073: The command "python $C:\Users\saam2_000\Documents\Programmation\OpenGL\sb6code-master\gl3w-master\build\glew..\..\gl3w_gen.py

:VCEnd" exited with code 9009.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets	122	5	glew


I don't know why it is so hard to get an OpenGL simple program working :(
Last edited on
bump
Topic archived. No new replies allowed.