3

VS 2010 で使用するために GLFW が正しくインストールされているかどうかをテストしようとしているときに、「宣言されていない識別子」および「識別子が宣言されていません」というコンパイラ エラーが発生します。

Visual Studio 2010 で使用する 最新の 32 ビット バイナリをGLFWからダウンロードしました。

glfw3.h および glfw3native.h ヘッダー ファイルは、Windows SDK フォルダーの include/gl フォルダーと、VS 2010 インストールの include フォルダーにあります。

glfw3.lib および glfw3dll.lib ファイルは、Windows SDK の lib フォルダーと VS 2010 インストールの lib フォルダーにあります。

glfw3.dll ファイルは、VS 2010 プロジェクトの .exe と同じフォルダーと System32 フォルダーにあります。

私のプロジェクトが正しいインクルード lib ディレクトリを指していないことが問題であるかどうかを判断するために、重複した場所が存在します。

Linker->Additional Dependencies には、glfw3.lib、glew32d.lib、opengl32.lib、glu32.lib があります。glfw3dll.lib を個別に、および glfw3.lib と組み合わせてインクルードしようとしましたが、同じ結果です。

ビルドログは次のとおりです。

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

コードは OpenGL 4 チュートリアルからのものです。最新のダウンロードを反映するように glfw ヘッダー ファイルを変更しました。つまり、glfw.h から 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;
}

他のほとんどの人がこれらのライブラリをリンクする際に問題を抱えているようですが、これはコンパイラ エラーですか?

4

2 に答える 2

2

GLFW のバージョン 3 では、glfwOpenWindowHint から glfwWindowHint など、いくつかの関数名が変更されました。

このページにはバージョンの変更が記載されているため、CTRL F を使用して新しい関数名を見つけます。

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

#include <GL/glfw3.h>また、フォルダ名が変更されたため、変更する必要があることがわかりまし#include <GLFW/glfw3.h>た(GLFWディレクトリをチェックインして、自分のものを確認してください)。

それが役立つことを願っています...

于 2013-07-20T10:20:20.567 に答える
0

今のようなものはありません#include "GL/glfw3.h"

glfwパッケージのソースファイルを抽出すると、フォルダが取得GLFWされるので、次のように含める必要があります

> #include "GLFW\glfw3.h"
于 2013-12-30T10:13:52.530 に答える