I’m learning how to use OpenGL and SDL2 in C++, I hav already installed gcc and all the dependencies (SDL2 GL GLEW GLFW)
I’m using VSCode 1.84.2 and gcc/g++ are latest.
The problem is, I’m somehow missing the cstddef.h header which is needed by GLFW. I tried uninstalling and installing gcc but it did not fix anything. Not sure what’s up as I’m new to VSCode and local C++ development.
Line that causes errors:
#include <cstddef.h>
Errors throw by VSCode:
1: #include errors detected based on information provided by the configurationProvider setting. Squiggles are disabled for this translation unit (/home/samuel/VSCode Projects/GameTest5/main.cpp).
2: cannot open source file "cstddef.h"
3: cstddef.h: No such file or directory
[ 50%] Building CXX object CMakeFiles/Game.dir/main.cpp.o
/home/user/VSCode Projects/GameTest5/main.cpp: In function ‘int main()’:
/home/user/VSCode Projects/GameTest5/main.cpp:8:23: error: expected initializer before ‘glfwCreateWindow’
8 | GLFWwindow window glfwCreateWindow(600, 600, "this", NULL, NULL);
| ^~~~~~~~~~~~~~~~
/home/user/VSCode Projects/GameTest5/main.cpp:9:28: error: ‘window’ was not declared in this scope
9 | glfwMakeContextCurrent(window);
| ^~~~~~
/home/user/VSCode Projects/GameTest5/main.cpp:10:23: error: ‘GLADloadproc’ was not declared in this scope
10 | gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
| ^~~~~~~~~~~~
/home/user/VSCode Projects/GameTest5/main.cpp:10:5: error: ‘gladLoadGLLoader’ was not declared in this scope
10 | gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
| ^~~~~~~~~~~~~~~~
/home/user/VSCode Projects/GameTest5/main.cpp:17:5: error: ‘unit32_t’ was not declared in this scope; did you mean ‘uint32_t’?
17 | unit32_t v;
| ^~~~~~~~
| uint32_t
/home/user/VSCode Projects/GameTest5/main.cpp:18:22: error: ‘v’ was not declared in this scope
18 | glGenBuffers(1, &v);
| ^
/home/user/VSCode Projects/GameTest5/main.cpp:18:5: error: ‘glGenBuffers’ was not declared in this scope; did you mean ‘glReadBuffer’?
18 | glGenBuffers(1, &v);
| ^~~~~~~~~~~~
| glReadBuffer
/home/user/VSCode Projects/GameTest5/main.cpp:19:5: error: ‘glBindBuffer’ was not declared in this scope; did you mean ‘glReadBuffer’?
19 | glBindBuffer(GL_ARRAY_BUFFER, v);
| ^~~~~~~~~~~~
| glReadBuffer
/home/user/VSCode Projects/GameTest5/main.cpp:20:5: error: ‘glBufferData’ was not declared in this scope
20 | glBufferData(GL_ARRAY_BUFFER, sizeof(t)*sizeof(t)/sizeof(t[0]), &t[0], GL_STATIC_DRAW)
| ^~~~~~~~~~~~
/home/user/VSCode Projects/GameTest5/main.cpp:22:5: error: ‘glEnableVertexAttribArray’ was not declared in this scope
22 | glEnableVertexAttribArray(0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/VSCode Projects/GameTest5/main.cpp:25:17: error: ‘GL_COLOR_ARRAY_BUFFER_BIT’ was not declared in this scope; did you mean ‘GL_COLOR_ARRAY_BUFFER_BINDING’?
25 | glClear(GL_COLOR_ARRAY_BUFFER_BIT);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| GL_COLOR_ARRAY_BUFFER_BINDING
make[2]: *** [CMakeFiles/Game.dir/build.make:76: CMakeFiles/Game.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Game.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
I don’t know it you missed my point or not. The one’s in our repo (which we mirror from arch-arm) is a year and a half old and it is not the same as in the glfw github. They have #include <stddef.h> not #include <cstddef.h> in their gitlab. Also the glfw-git in AUR is flagged out of date. You need to rebuild gufw with the one in their git. Then hope that the code you borrowed from youtube is not old enough to use strings that was in cstddef.h which appears to now be depreciated.