OpenGL

Unresolved External Symbol ERROR

Sometimes the error of format:

DTrack.obj : error LNK2019: unresolved external symbol _gethostbyname@4 referenced in function "unsigned int __cdecl ip_name2ip(char const *)" (?ip_name2ip@@YAIPBD@Z)
1>istest_haplo.obj : error LNK2001: unresolved external symbol _gethostbyname@4

can be solved by linking Ws2_32.lib to the Project Properties->Linker-> Input-> Additional Dependencies.


GLUT

  • Download GLUT from Nate Robin’s Site
  • Put
    • glut.h to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include
    • glut32.lib to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
    • glut32.dll to C:\Windows\System32\ or C:\Windows\SysWOW64
  • And, we are done

 


Linking to OpenGL libraries

When you have created an Empty project in VS 2008, add a new c++ source file (.cpp).

  • Open Project properties
  • Configuration Properties -> Linker -> Input
  • Select Configuration Drop-down box
    • Select All Configurations
    • It changes settings for both Debug and Release configurations
  • In the Additional Dependencies box, add opengl32.lib glu32.lib
  • Click OK

‘exit’ redefinition error in OpenGL

An opengl error that shows up mostly in VS 2003 and VS 2005:

    microsoft visual studio 8\vc\include\stdlib.h(433) : error C2381: 'exit' : 
    redefinition; __declspec(noreturn) differs \includes\gl\glut.h(146) : 
    see declaration of 'exit'

This error is caused by including glut.h before stdlib.h. So just by reversing the order of inclusion we can remove this error:

     #include <GL/glut.h>
     #include <stdlib.h>
to
     #include <stdlib.h>
     #include <GL/glut.h>