Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glfw undeclared identifiers after linking with Visual Studio 2010

I am getting 'undeclared identifier' and 'identifier not declared' compiler errors while trying to test whether I've installed GLFW correctly for use with VS 2010.

I downloaded the latest 32 bit binaries from GLFW to be used with Visual Studio 2010.

The glfw3.h and glfw3native.h header file is in the include/gl folder of my Windows SDKs folder and the include folder of my VS 2010 install.

The glfw3.lib and glfw3dll.lib files are in the Windows SDKs lib folder and the VS 2010 install's lib folder.

The glfw3.dll file is in the same folder as the .exe of my VS 2010 project and in my System32 folder.

The duplicate locations exist to determine whether the issue is that my project is not pointing to the correct include, lib directories.

In Linker->Additional Dependencies, I have glfw3.lib, glew32d.lib, opengl32.lib and glu32.lib. I have tried including glfw3dll.lib separately and in combination with glfw3.lib, same result.

Here is the build log:

Build started 7/20/2013 01:00:28.
 1>Project "j:\Users\Guy\documents\visual studio 2010\Projects\OpenGL4Test\OpenGL4Test\OpenGL4Test.vcxproj" on node 2 (build target(s)).
 1>InitializeBuildStatus:
     Touching "Debug\OpenGL4Test.unsuccessfulbuild".
   ClCompile:
     C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
     main.cpp
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(13): error C2065: 'GLFW_OPENGL_VERSION_MAJOR' : undeclared identifier
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(13): error C3861: 'glfwOpenWindowHint': identifier not found
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(14): error C2065: 'GLFW_OPENGL_VERSION_MINOR' : undeclared identifier
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(14): error C3861: 'glfwOpenWindowHint': identifier not found
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(15): error C3861: 'glfwOpenWindowHint': identifier not found
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(16): error C3861: 'glfwOpenWindowHint': identifier not found
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(19): error C2065: 'GLFW_WINDOW' : undeclared identifier
 1>j:\users\Guy\documents\visual studio 2010\projects\opengl4test\opengl4test\main.cpp(19): error C3861: 'glfwOpenWindow': identifier not found
 1>Done Building Project "j:\Users\Guy\documents\visual studio 2010\Projects\OpenGL4Test\OpenGL4Test\OpenGL4Test.vcxproj" (build target(s)) -- FAILED.
Build FAILED.
Time Elapsed 00:00:00.33

And the code comes from the an OpenGL 4 tutorial, I changed the glfw header file to reflect the latest download, i.e. from glfw.h to glfw3.h:

#include <GL/glew.h> // include GLEW and new version of GL on Windows
#include <GL/glfw3.h> // GLFW helper library
#include <stdio.h>
#include <string>

int main () {
  // start GL context and O/S window using the GLFW helper library
  glfwInit ();

  // "hint" that the version 4.2 should be run with no back-compat stuff
  int major = 4;
    int minor = 2;
    glfwOpenWindowHint (GLFW_OPENGL_VERSION_MAJOR, major);
    glfwOpenWindowHint (GLFW_OPENGL_VERSION_MINOR, minor);
    glfwOpenWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwOpenWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

  // open a window of sixe 640x480 with 8bpp and 24 bits for depth sorting
  glfwOpenWindow(640, 480, 8, 8, 8, 8, 24, 8, GLFW_WINDOW);
  // start GLEW extension handler
  glewInit ();

  // get version info
  const GLubyte* renderer = glGetString (GL_RENDERER); // get renderer string
  const GLubyte* version = glGetString (GL_VERSION); // version as a string
  printf("Renderer: %s\n", renderer);
  printf("OpenGL version supported %s\n", version);

    // tell GL to only draw onto a pixel if the shape is closer to the viewer
  glEnable (GL_DEPTH_TEST); // enable depth-testing
  glDepthFunc (GL_LESS); // depth-testing interprets a smaller value as "closer"

  /* OTHER STUFF GOES HERE NEXT */

  // close GL context and any other GLFW resources
  glfwTerminate();
  return 0;
}

It seems that most other people have problems linking these libraries, but these are compiler errors?

like image 749
user52207 Avatar asked Dec 10 '25 02:12

user52207


1 Answers

Some function names were changed in Version 3 of GLFW, such as glfwOpenWindowHint to glfwWindowHint.

This page gives the version changes, so use CTRL F to find the new function names:

http://www.glfw.org/changelog.html

Also, I found I needed to change #include <GL/glfw3.h> to #include <GLFW/glfw3.h> as the folder name was changed (check in the GLFW directory to see what yours is).

Hope that helps...

like image 71
Richard Jones Avatar answered Dec 12 '25 00:12

Richard Jones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!