libepoxy icon indicating copy to clipboard operation
libepoxy copied to clipboard

Build failure on dispatch_egl: error: unknown type name 'EGLDisplay'

Open barracuda156 opened this issue 1 year ago • 3 comments

Compilation fails with Egl option enabled on 10.6.8:

../anholt-libepoxy-70a20c6/src/dispatch_egl.c: In function 'epoxy_conservative_egl_version':
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:33:5: error: unknown type name 'EGLDisplay'; did you mean 'Display'?
   33 |     EGLDisplay dpy = eglGetCurrentDisplay();
      |     ^~~~~~~~~~
      |     Display
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:33:22: error: implicit declaration of function 'eglGetCurrentDisplay'; did you mean 'glXGetCurrentDisplay'? [-Werror=implicit-function-declaration]
   33 |     EGLDisplay dpy = eglGetCurrentDisplay();
      |                      ^~~~~~~~~~~~~~~~~~~~
      |                      glXGetCurrentDisplay
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:33:22: warning: nested extern declaration of 'eglGetCurrentDisplay' [-Wnested-externs]
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:38:12: error: implicit declaration of function 'epoxy_egl_version'; did you mean 'epoxy_gl_version'? [-Werror=implicit-function-declaration]
   38 |     return epoxy_egl_version(dpy);
      |            ^~~~~~~~~~~~~~~~~
      |            epoxy_gl_version
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:38:12: warning: nested extern declaration of 'epoxy_egl_version' [-Wnested-externs]
../anholt-libepoxy-70a20c6/src/dispatch_egl.c: At top level:
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:61:19: error: unknown type name 'EGLDisplay'; did you mean 'Display'?
   61 | epoxy_egl_version(EGLDisplay dpy)
      |                   ^~~~~~~~~~
      |                   Display
../anholt-libepoxy-70a20c6/src/dispatch_egl.c: In function 'epoxy_conservative_has_egl_extension':
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:79:12: error: implicit declaration of function 'epoxy_has_egl_extension'; did you mean 'epoxy_has_gl_extension'? [-Werror=implicit-function-declaration]
   79 |     return epoxy_has_egl_extension(eglGetCurrentDisplay(), ext);
      |            ^~~~~~~~~~~~~~~~~~~~~~~
      |            epoxy_has_gl_extension
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:79:12: warning: nested extern declaration of 'epoxy_has_egl_extension' [-Wnested-externs]
../anholt-libepoxy-70a20c6/src/dispatch_egl.c: At top level:
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:94:25: error: unknown type name 'EGLDisplay'; did you mean 'Display'?
   94 | epoxy_has_egl_extension(EGLDisplay dpy, const char *ext)
      |                         ^~~~~~~~~~
      |                         Display
../anholt-libepoxy-70a20c6/src/dispatch_egl.c:107:1: warning: no previous prototype for 'epoxy_has_egl' [-Wmissing-prototypes]
  107 | epoxy_has_egl(void)
      | ^~~~~~~~~~~~~
cc1: some warnings being treated as errors

P. S. mesa @19.0.8_1+osmesa+python27 (with Egl support enabled), gcc12 @12.2.0.

barracuda156 avatar Sep 01 '22 13:09 barracuda156

After EGL enabled and dylib location set, build fails with:

../anholt-libepoxy-70a20c6/test/egl_without_glx.c: In function 'dlopen':
../anholt-libepoxy-70a20c6/test/egl_without_glx.c:69:30: error: 'RTLD_NEXT' undeclared (first use in this function); did you mean 'RTLD_NOW'?
   69 |     dlopen_unwrapped = dlsym(RTLD_NEXT, "dlopen");
      |                              ^~~~~~~~~
      |                              RTLD_NOW

../anholt-libepoxy-70a20c6/test/egl_has_extension_nocontext.c: In function 'main':
../anholt-libepoxy-70a20c6/test/egl_has_extension_nocontext.c:61:24: error: implicit declaration of function 'strndup' [-Werror=implicit-function-declaration]
   61 |         an_extension = strndup(extensions, first_space - extensions);
      |                        ^~~~~~~
../anholt-libepoxy-70a20c6/test/egl_has_extension_nocontext.c:61:24: warning: incompatible implicit declaration of built-in function 'strndup' [-Wbuiltin-declaration-mismatch]
cc1: some warnings being treated as errors

../anholt-libepoxy-70a20c6/test/egl_epoxy_api.c: In function 'main':
../anholt-libepoxy-70a20c6/test/egl_epoxy_api.c:134:24: error: implicit declaration of function 'strndup' [-Werror=implicit-function-declaration]
  134 |         an_extension = strndup(extensions, first_space - extensions);
      |                        ^~~~~~~
../anholt-libepoxy-70a20c6/test/egl_epoxy_api.c:134:24: warning: incompatible implicit declaration of built-in function 'strndup' [-Wbuiltin-declaration-mismatch]
cc1: some warnings being treated as errors

barracuda156 avatar Sep 01 '22 14:09 barracuda156

_DARWIN_C_SOURCE definition should be added, that fixes error: 'RTLD_NEXT' undeclared.

barracuda156 avatar Sep 01 '22 14:09 barracuda156

So, EGLDisplay error is fixed like this:

--- src/dispatch_common.h.orig	2022-02-17 19:56:12.000000000 +0700
+++ src/dispatch_common.h	2022-09-01 21:11:53.000000000 +0700
@@ -28,7 +28,7 @@
 #define PLATFORM_HAS_GLX ENABLE_GLX
 #define PLATFORM_HAS_WGL 1
 #elif defined(__APPLE__)
-#define PLATFORM_HAS_EGL 0 
+#define PLATFORM_HAS_EGL ENABLE_EGL
 #define PLATFORM_HAS_GLX ENABLE_GLX
 #define PLATFORM_HAS_WGL 0
 #elif defined(ANDROID)

--- src/dispatch_common.c.orig	2022-02-17 19:56:12.000000000 +0700
+++ src/dispatch_common.c	2022-09-01 21:11:35.000000000 +0700
@@ -174,7 +174,8 @@
 #include "dispatch_common.h"
 
 #if defined(__APPLE__)
-#define GLX_LIB "/opt/X11/lib/libGL.1.dylib"
+#define GLX_LIB "@PREFIX@/lib/libGL.1.dylib"
+#define EGL_LIB "@PREFIX@/lib/libEGL.1.dylib"
 #define OPENGL_LIB "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
 #define GLES1_LIB "libGLESv1_CM.so"
 #define GLES2_LIB "libGLESv2.so"

Obviously however, libEGL.1.dylib should be installed first, it is not there by default.

barracuda156 avatar Sep 05 '22 18:09 barracuda156