EGL failed to get devices with Nvidia driver 384.66

System: CentOS Linux release 7.2.1511 (Core)
Driver: NVIDIA-SMI 384.66

eglQueryDevicesEXT always get 0 devices.


[Code]

#define EGL_EGLEXT_PROTOTYPES
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <stdio.h>

int main()
{
EGLDisplay eglDpy;

static const int MAX_DEVICES = 4;
EGLDeviceEXT eglDevs[MAX_DEVICES];
EGLint numDevices;

PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)
eglGetProcAddress(“eglQueryDevicesEXT”);

eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);

printf(“Detected %d devices\n”, numDevices);

PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)
eglGetProcAddress(“eglGetPlatformDisplayEXT”);

eglDpy = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT,
eglDevs[1], 0);

EGLint major, minor;
eglInitialize(eglDpy, &major, &minor);

// …

return 0;
}

For anyone who stumbled upon this post as I do, the problem could be linking to the wrong EGL libraries. After I change the link path to the libraries in /usr/lib/nvidia-410 my code works.

Here are some more posts that are helpful: