471,049 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

Why .cpp program does not see the GL/glew.h file?

In the directory where the program is located (C:\2022\Work\programming\engineering\my-works\my_game\programs), there is also the glew-2.1.0 folder, which contains the include folder, which contains the GL folder, which contains header file glew.h. When I try to run the program in Visual Studio Code 1.69 (Windows 10 Home), the following text appears in the terminal:
"PS C:\2022\Work\programming\engineering\my-works\my_game\programs> cd "c:\2022\Work\programming\engineering\my-works\my_game\programs\" ; if ($?) { g++ open_gl_1_test.cpp -o open_gl_1_test } ;if
($?) { .\open_gl_1_test }
open_gl_1_test.cpp:1:10: fatal error: GL/glew.h: No such file or directory
1 | #include <GL/glew.h>
| ^~~~~~~~~~~
compilation terminated.
PS C:\2022\Work\programming\engineering\my-works\my_game\programs>".

Here is the program code itself:

Expand|Select|Wrap|Line Numbers
  1. #include <GL/glew.h>
  2. #include <GLFW/glfw3.h>
  3. #include <iostream>
  4. using namespace std;
  5. void init(GLFWwindow *window) {}
  6. void display(GLFWwindow *window, double currentTime)
  7. {
  8.     glClearColor(1.0, 0.0, 0.0, 1.0);
  9.     glClear(GL_COLOR_BUFFER_BIT);
  10. }
  11. int main(void)
  12. {
  13.     if (!glfwInit())
  14.     {
  15.         exit(EXIT_FAILURE);
  16.     }
  17.     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
  18.     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  19.     GLFWwindow *window = glfwCreateWindow(600, 600, "Chapter2 - program1", NULL, NULL);
  20.     glfwMakeContextCurrent(window);
  21.     if (glewInit() != GLEW_OK)
  22.     {
  23.         exit(EXIT_FAILURE);
  24.     }
  25.     glfwSwapInterval(1);
  26.     init(window);
  27.     while (!glfwWindowShouldClose(window))
  28.     {
  29.         display(window, glfwGetTime());
  30.         glfwSwapBuffers(window);
  31.         glfwPollEvents();
  32.     }
  33.     glfwDestroyWindow(window);
  34.     glfwTerminate();
  35.     exit(EXIT_SUCCESS);
  36. }
How to ensure that the program can include the glew.h header file?
2 Weeks Ago #1
1 7702
dev7060
581 Expert 512MB
In the directory where the program is located (C:\2022\Work\programming\engineering\my-works\my_game\programs), there is also the glew-2.1.0 folder, which contains the include folder, which contains the GL folder, which contains header file glew.h. When I try to run the program in Visual Studio Code 1.69 (Windows 10 Home), the following text appears in the terminal:
"PS C:\2022\Work\programming\engineering\my-works\my_game\programs> cd "c:\2022\Work\programming\engineering\my-works\my_game\programs\" ; if ($?) { g++ open_gl_1_test.cpp -o open_gl_1_test } ;if
($?) { .\open_gl_1_test }
open_gl_1_test.cpp:1:10: fatal error: GL/glew.h: No such file or directory
1 | #include <GL/glew.h>
| ^~~~~~~~~~~
compilation terminated.
PS C:\2022\Work\programming\engineering\my-works\my_game\programs>".
Use relative path with double quotes.
Expand|Select|Wrap|Line Numbers
  1. #include "../myglewfolder/include/GL/glew.h"
The project directory can also be added to the compiler include path.
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Cyril Vi?ville | last post: by
3 posts views Thread by Reggie | last post: by
13 posts views Thread by James Reid | last post: by
5 posts views Thread by sjayaramit | last post: by
232 posts views Thread by robert maas, see http://tinyurl.com/uh3t | last post: by
2 posts views Thread by Kreators | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.