4

Recently I started to learn OpenGL and; in turn, began to read the OpenGL SuperBible 6th edition, which uses OpenGL 4.3.

My problem is in the sb6.h header file, because in the book it was written that this is a c++ header file that defines a namespace called sb6 that includes the declaration of an application class.

When I try to compile my program, my C++ IDE(Visual Studio 2010) throws an error stating that such a header file cannot be found.

So maybe one of you heard about this problem or also started to read this book and knows how to fix this problem; if so please reply.

#include "sb6.h"

//derive my_application from sb6:application

class my_application : public sb6.application
{
public : 

   //Rendering function
   void render(double currentTime){

   //Simply clear the window red
   static const GLfloat red[] = {1.0f , 0.0f , 0.0f , 1.0f};

  glClearBufferfv(GL_COLOR, 0 , red) ; 
}
Cartier
  • 429
  • 4
  • 15
Nicholas
  • 3,529
  • 2
  • 23
  • 31
  • 1
    The first question then becomes: do you have that file? If you look at the Github for the book's sources, it's there: https://github.com/openglsuperbible/sb6code – Bart Nov 05 '13 at 13:18
  • @Bart , no i dont have it . I will downloadd it from your link – Nicholas Nov 05 '13 at 13:19
  • Even though I started learning OpenGL (1.2) from the super bible, but it seems now to me that it's better as a reference rather than a tutorial. Take a look at [this book](http://www.arcsynthesis.org/gltut/) also, perhaps you would find it easier to learn. – Shahbaz Nov 05 '13 at 13:24
  • Im familiar with OpenGL , but this header file was messing up with me – Nicholas Nov 05 '13 at 13:30

1 Answers1

9

the sb6.h file you are looking for is located at: https://github.com/openglsuperbible/sb6code/blob/master/include/sb6.h You can also navigate about that project and see the rest of the source/retrieve any other files you need. When you copy them to a local drive/directory make sure to add the path of the new directory containing headers to your include path and any libs to the lib path etc, as otherwise you will still meet the same error.

Well, unless you add them straight to the project dir (not recommended, as you will end up with massive repetition of content over all your gl projects, better to place them in one location and add the paths) Let me know if you need a hand with defining the paths.

Additional:

To include the headers, libs etc. just do the following:

Download all the sb6 project, then save somewhere (for example c:\sb6\ ) Then, go to Property Pages -> VC++ Directories -> Include Directories and add the c:\sb6\include\ path here header files then you will want to add the libraries via: Property Pages -> VC++ Directories -> Library Directories to here: lib files and finally add your source code directory via: Property Pages -> VC++ Directories -> Source Directories here: source files

To fix error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

This is normally a linker problem and most often happens from the wrong project type being selected (ie picking a windows program project and not a windows console one). It can be fixed by doing the following:

Go to Project -> Properties -> Configuration Properties -> Linker -> System and on the entry for Subsystem change it to Console

Shown here: Change subsystem to console

Let me know how you get on and I can expand if needed.

GMasucci
  • 2,834
  • 22
  • 42
  • Yes i need some help with linking the headerfiles with the project – Nicholas Nov 05 '13 at 13:55
  • Hi Nicholas, was just editing the post and screen-grabbing updated now:) – GMasucci Nov 05 '13 at 14:31
  • Okey , now i get this error error C2504: 'sb6' : base class undefined – Nicholas Nov 06 '13 at 06:25
  • The previous error with sb6 base class undefined i fixed it . Now its telling me that error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup I know this is a issue that i dont have my main function but as far as i understand DECLARE_MAIN(my_application) ; – Nicholas Nov 06 '13 at 07:06
  • DECLARE_MAIN(my_application) ; Stands for function main .So i dont know why this error is showing up – Nicholas Nov 06 '13 at 07:07
  • Hi, I believe this error happens when you have the wrong project type selected: for example if you made a windows program and are coding for a console application or vice versa. I have added a section on how to fix this error to the answer:) – GMasucci Nov 06 '13 at 08:20
  • Yes, i tried it before and did not worked .My project is also an console project. Also i tryed to make it windows application and it doesnt work neither. – Nicholas Nov 06 '13 at 08:34
  • could you post more detail on the error please and I can try and recreate it? Also, strange as it sounds try a clean and rebuild, you wouldnt believe how often that can help. – GMasucci Nov 06 '13 at 08:48
  • Ok , lets start it from beginning . I have a header file with the code included from above . I made the link with sb6 folder as you said . Perfect. My project is a console project , and in properties on advanced option i also have the selected option Console . I dont know how to do a clean (maybe that is debuging) , but when i build it the error is : 1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup 1>C:\Users\Nico\Desktop\Test1\Debug\Test1.exe : fatal error LNK1120: 1 unresolved externals – Nicholas Nov 06 '13 at 09:06
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/40623/discussion-between-gmasucci-and-nicholas) – GMasucci Nov 06 '13 at 09:09
  • I will need to look at this tonight but will be available later on (post 6pm gmt) and can feed back more information. – GMasucci Nov 06 '13 at 09:58