nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.58k stars 609 forks source link

Build in wayland fails. #340

Closed Mederim closed 2 years ago

Mederim commented 2 years ago

I have find some issues when i tried to build glew to egl system.

cc -DGLEW_NO_GLU -DGLEW_BUILD -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL  -o tmp/linux-egl/default/shared/glew.o -c src/glew.c
sed \
    -e "s|@prefix@|/usr|g" \
    -e "s|@libdir@|/usr/lib64|g" \
    -e "s|@exec_prefix@|/usr/bin|g" \
    -e "s|@includedir@|/usr/include/GL|g" \
    -e "s|@version@|2.2.0|g" \
    -e "s|@cflags@||g" \
    -e "s|@libname@|GLEW|g" \
    -e "s|@libgl@|-lEGL -lGL|g" \
    -e "s|@requireslib@|glu|g" \
    < glew.pc.in > glew.pc
cc -DGLEW_NO_GLU -DGLEW_STATIC -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL  -o tmp/linux-egl/default/static/glew.o -c src/glew.c
cc -DGLEW_NO_GLU -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL  -o tmp/linux-egl/default/shared/glewinfo.o -c src/glewinfo.c
cc -DGLEW_NO_GLU -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL  -o tmp/linux-egl/default/shared/visualinfo.o -c src/visualinfo.c
In file included from include/GL/eglew.h:107,
                 from src/glew.c:43:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:134: tmp/linux-egl/default/static/glew.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from include/GL/eglew.h:107,
                 from src/glew.c:43:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
In file included from include/GL/eglew.h:107,
                 from src/visualinfo.c:41:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
compilation terminated.
make: *** [Makefile:138: tmp/linux-egl/default/shared/glew.o] Error 1
make: *** [Makefile:200: tmp/linux-egl/default/shared/visualinfo.o] Error 1
In file included from include/GL/eglew.h:107,
                 from src/glewinfo.c:38:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:196: tmp/linux-egl/default/shared/glewinfo.o] Error 1
nigels-com commented 2 years ago

Right. So in Wayland mode, no X11?

Mederim commented 2 years ago

Yeah only wayland support

~ $ echo $XDG_SESSION_TYPE
wayland

I had a problem with this in freeglut but i used -DEGL_NO_X11 in my ~/.profile but not worked in glew:

In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_ext.c:29:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_callbacks.c:28:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_callbacks.c:28:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
compilation terminated.
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_cursor.c:28:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_cursor.c:28:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/freeglut.dir/build.make:76: CMakeFiles/freeglut.dir/src/fg_callbacks.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/freeglut_static.dir/build.make:90: CMakeFiles/freeglut_static.dir/src/fg_cursor.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_display.c:28:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/freeglut.dir/build.make:90: CMakeFiles/freeglut.dir/src/fg_cursor.c.o] Error 1
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_ext.c:29:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/freeglut_static.dir/build.make:118: CMakeFiles/freeglut_static.dir/src/fg_ext.c.o] Error 1
make[2]: *** [CMakeFiles/freeglut_static.dir/build.make:76: CMakeFiles/freeglut_static.dir/src/fg_callbacks.c.o] Error 1
make[2]: *** [CMakeFiles/freeglut.dir/build.make:118: CMakeFiles/freeglut.dir/src/fg_ext.c.o] Error 1
make[2]: *** [CMakeFiles/freeglut_static.dir/build.make:104: CMakeFiles/freeglut_static.dir/src/fg_display.c.o] Error 1
[  6%] Building C object CMakeFiles/freeglut_static.dir/src/fg_font_data.c.o
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_display.c:28:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/freeglut.dir/build.make:104: CMakeFiles/freeglut.dir/src/fg_display.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:527: CMakeFiles/freeglut.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /usr/include/EGL/egl.h:39,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut_std.h:136,
                 from /home/hellboy/Downloads/freeglut-3.2.1/include/GL/freeglut.h:17,
                 from /home/hellboy/Downloads/freeglut-3.2.1/src/fg_font_data.c:53:
/usr/include/EGL/eglplatform.h:134:10: fatal error: X11/Xlib.h: No such file or directory
  134 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/freeglut_static.dir/build.make:132: CMakeFiles/freeglut_static.dir/src/fg_font_data.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:397: CMakeFiles/freeglut_static.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
nigels-com commented 2 years ago

This branch seems to work for me: PR #341 Could you give that a try?

Mederim commented 2 years ago

Tried this branch and gets another error:

~/Downloads/glew-linux-wayland $ make SYSTEM=linux-wayland
mkdir lib
cc -DGLEW_NO_GLU -DGLEW_BUILD -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL -DEGL_NO_X11  -o tmp/linux-wayland/default/shared/glew.o -c src/glew.c
sed \
    -e "s|@prefix@|/usr/local|g" \
    -e "s|@libdir@|/usr/local/lib64|g" \
    -e "s|@exec_prefix@|/usr/local/bin|g" \
    -e "s|@includedir@|/usr/local/include/GL|g" \
    -e "s|@version@|2.2.0|g" \
    -e "s|@cflags@||g" \
    -e "s|@libname@|GLEW|g" \
    -e "s|@libgl@|-lEGL -lGL|g" \
    -e "s|@requireslib@|glu|g" \
    < glew.pc.in > glew.pc
cc -DGLEW_NO_GLU -DGLEW_STATIC -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL -DEGL_NO_X11  -o tmp/linux-wayland/default/static/glew.o -c src/glew.c
cc -DGLEW_NO_GLU -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL -DEGL_NO_X11  -o tmp/linux-wayland/default/shared/glewinfo.o -c src/glewinfo.c
cc -DGLEW_NO_GLU -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL -DEGL_NO_X11  -o tmp/linux-wayland/default/shared/visualinfo.o -c src/visualinfo.c
src/visualinfo.c: In function 'VisualInfo':
src/visualinfo.c:261:24: warning: unused parameter 'ctx' [-Wunused-parameter]
  261 | VisualInfo (GLContext* ctx)
      |             ~~~~~~~~~~~^~~
src/visualinfo.c: In function 'CreateContext':
src/visualinfo.c:1050:37: warning: unused parameter 'ctx' [-Wunused-parameter]
 1050 | GLboolean CreateContext (GLContext* ctx)
      |                          ~~~~~~~~~~~^~~
src/glewinfo.c: In function 'glewCreateContext':
src/glewinfo.c:18927:24: warning: unused variable 'minorVersion' [-Wunused-variable]
18927 |   EGLint majorVersion, minorVersion;
      |                        ^~~~~~~~~~~~
src/glewinfo.c:18927:10: warning: unused variable 'majorVersion' [-Wunused-variable]
18927 |   EGLint majorVersion, minorVersion;
      |          ^~~~~~~~~~~~
src/glewinfo.c:18922:51: warning: unused parameter 'params' [-Wunused-parameter]
18922 | GLboolean glewCreateContext (struct createParams *params)
      |                              ~~~~~~~~~~~~~~~~~~~~~^~~~~~
ar rv lib/libGLEW.a tmp/linux-wayland/default/static/glew.o
ar: creating lib/libGLEW.a
a - tmp/linux-wayland/default/static/glew.o
strip -x lib/libGLEW.a
cc -shared -Wl,-soname=libGLEW.so.2.2 -o lib/libGLEW.so.2.2.0 tmp/linux-wayland/default/shared/glew.o -L/usr/X11R6/lib64 -L/usr/lib64 -lEGL -lGL 
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [Makefile:123: lib/libGLEW.so.2.2.0] Error 1
nigels-com commented 2 years ago

Yes, you'll still need to link OpenGL. Perhaps -lOpenGL instead of -lGL ?

Mederim commented 2 years ago

Installed libglvnd and put -lOpenGL thats worked:

~/Downloads/glew-linux-wayland $ make SYSTEM=linux-wayland
cc -shared -Wl,-soname=libGLEW.so.2.2 -o lib/libGLEW.so.2.2.0 tmp/linux-wayland/default/shared/glew.o -L/usr/X11R6/lib64 -L/usr/lib64 -lEGL -lOpenGL 
sed \
    -e "s|@prefix@|/usr/local|g" \
    -e "s|@libdir@|/usr/local/lib64|g" \
    -e "s|@exec_prefix@|/usr/local/bin|g" \
    -e "s|@includedir@|/usr/local/include/GL|g" \
    -e "s|@version@|2.2.0|g" \
    -e "s|@cflags@||g" \
    -e "s|@libname@|GLEW|g" \
    -e "s|@libgl@|-lEGL -lOpenGL|g" \
    -e "s|@requireslib@|glu|g" \
    < glew.pc.in > glew.pc
ar rv lib/libGLEW.a tmp/linux-wayland/default/static/glew.o
ar: creating lib/libGLEW.a
a - tmp/linux-wayland/default/static/glew.o
strip -x lib/libGLEW.a
ln -sf libGLEW.so.2.2.0 lib/libGLEW.so.2.2
ln -sf libGLEW.so.2.2.0 lib/libGLEW.so
strip -x lib/libGLEW.so.2.2.0
cc -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL -DEGL_NO_X11 -o bin/glewinfo tmp/linux-wayland/default/shared/glewinfo.o -Llib -Wl,-Bdynamic -lGLEW -L/usr/X11R6/lib64 -L/usr/lib64 -lEGL -lOpenGL
cc -O2 -Wall -W -Wshadow -pedantic -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -DGLEW_EGL -DEGL_NO_X11 -o bin/visualinfo tmp/linux-wayland/default/shared/visualinfo.o -Llib -Wl,-Bdynamic -lGLEW -L/usr/X11R6/lib64 -L/usr/lib64 -lEGL -lOpenGL
strip -x bin/visualinfo
strip -x bin/glewinfo
~/Downloads/glew-linux-wayland $ ldd  lib/libGLEW.so
    ldd (0x7f3224909000)
    libEGL.so.1 => /lib/libEGL.so.1 (0x7f3224800000)
    libOpenGL.so.0 => /lib/libOpenGL.so.0 (0x7f32247d3000)
    libc.so => ldd (0x7f3224909000)
    libgbm.so.1 => /lib/libgbm.so.1 (0x7f32247c2000)
    libglapi.so.0 => /lib/libglapi.so.0 (0x7f322475a000)
    libexpat.so.1 => /lib/libexpat.so.1 (0x7f3224726000)
    libdrm.so.2 => /lib/libdrm.so.2 (0x7f322470e000)
    libwayland-client.so.0 => /lib/libwayland-client.so.0 (0x7f32246fb000)
    libwayland-server.so.0 => /lib/libwayland-server.so.0 (0x7f32246e3000)
    libstdc++.so.6 => /lib/libstdc++.so.6 (0x7f3224473000)
    libGLdispatch.so.0 => /lib/libGLdispatch.so.0 (0x7f32243ba000)
    libffi.so.8 => /lib/libffi.so.8 (0x7f32243ad000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7f3224394000)

@nigels-com but why not link with GLES instead of OpenGL like Freeglut?

nigels-com commented 2 years ago

ES is not supported.

Mederim commented 2 years ago

Will be in future?

nigels-com commented 2 years ago

No plans.