Open Sigmanificient opened 4 months ago
on which distro are you on? and are you using wayland or xorg?
on which distro are you on? and are you using wayland or xorg?
I use NixOS 23.11
with Xorg
Try this:
touch glfw.c
nvim glfw.c
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
gcc -o glfw glfw.c -lglfw -lGL
./glfw
The binary do not produce any output.
I went ahead and added the following changes to retrieve information on what could fail.
--- a/test.c 2024-05-10 16:35:42.910592019 +0200
+++ b/test.c 2024-05-10 16:35:21.863102192 +0200
@@ -1,4 +1,5 @@
#include <GLFW/glfw3.h>
+#include <stdio.h>
int main(void)
@@ -7,6 +8,7 @@
/* Initialize the library */
if (!glfwInit()) {
+ perror("1");
return -1;
}
@@ -15,6 +17,7 @@
if (!window)
{
glfwTerminate();
+ perror("2");
return -1;
}
And now a error is showing up:
$ ./glfw
2: Resource temporarily unavailable
I was wondering if this could be an issue with my integrated graphics chipset, and tried runnint it by using my nvidia card:
$ nvidia-offload ./glfw
Trying the same with lyssa
, however, was not successful:
$ nvidia-offload /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/lyssa
Lyssa: [ERROR]: Failed to create GLFW window 'Lyssa Music Player'.
[LEIF ERROR]: Failed to initialize Glad.
[1] 311343 segmentation fault (core dumped) nvidia-offload /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/lyssa
$ valgrind --trace-children=yes -- nvidia-offload /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/lyssa
==324972== Memcheck, a memory error detector
==324972== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==324972== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==324972== Command: /run/current-system/sw/bin/nvidia-offload /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/lyssa
==324972==
==324972== Memcheck, a memory error detector
==324972== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==324972== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==324972== Command: /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/lyssa
==324972==
==324972== Memcheck, a memory error detector
==324972== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==324972== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==324972== Command: /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/.lyssa-wrapped
==324972==
Lyssa: [ERROR]: Failed to create GLFW window 'Lyssa Music Player'.
[LEIF ERROR]: Failed to initialize Glad.
==324972== Invalid read of size 8
==324972== at 0x4872BAD: glfwSetFramebufferSizeCallback (in /nix/store/4ja9a94kxjqwm65c5bpnrnsa5rffb0ij-glfw-3.4/lib/libglfw.so.3.4)
==324972== by 0x40CF7B: main (in /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/.lyssa-wrapped)
==324972== Address 0x308 is not stack'd, malloc'd or (recently) free'd
==324972==
==324972==
==324972== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==324972== Access not within mapped region at address 0x308
==324972== at 0x4872BAD: glfwSetFramebufferSizeCallback (in /nix/store/4ja9a94kxjqwm65c5bpnrnsa5rffb0ij-glfw-3.4/lib/libglfw.so.3.4)
==324972== by 0x40CF7B: main (in /nix/store/f73fkvh25phx0i0645zcyfnnciy3qryg-lyssa/bin/.lyssa-wrapped)
==324972== If you believe this happened as a result of a stack
==324972== overflow in your program's main thread (unlikely but
==324972== possible), you can try to increase the size of the
==324972== main thread stack using the --main-stacksize= flag.
==324972== The main thread stack size used in this run was 8388608.
==324972==
==324972== HEAP SUMMARY:
==324972== in use at exit: 752,212 bytes in 1,064 blocks
==324972== total heap usage: 22,262 allocs, 21,198 frees, 4,163,112 bytes allocated
==324972==
==324972== LEAK SUMMARY:
==324972== definitely lost: 0 bytes in 0 blocks
==324972== indirectly lost: 0 bytes in 0 blocks
==324972== possibly lost: 0 bytes in 0 blocks
==324972== still reachable: 752,212 bytes in 1,064 blocks
==324972== suppressed: 0 bytes in 0 blocks
==324972== Rerun with --leak-check=full to see details of leaked memory
==324972==
==324972== For lists of detected and suppressed errors, rerun with: -s
==324972== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
Maybe this could be related, i'm not sure: https://stackoverflow.com/questions/68051588/segmentation-fault-with-glviewport-opengl-c-programming-with-glfw-and-glad
i mean you could try removing glViewport from leif.c just search for it and remove every line where it is used. then rebuild leif and lyssa and try if that fixes it.
Unfortunately, it doesn't seems to help
I had this error when running the binary
I have the
glad
binary inPATH