Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7069

Undefined references to EGL functions? [duplicate]

$
0
0

I am trying to compile the program below and run the executable on Ubuntu without UI. I am working in a Kubeflow notebook. This is a preliminary test to check that everything works fine in order to run this repo.

When I run the script, I get the error messages:

/usr/bin/ld: /tmp/cciku4KL.o: in function `main':test.cpp:(.text+0x21): undefined reference to `eglGetDisplay'/usr/bin/ld: test.cpp:(.text+0x74): undefined reference to `eglInitialize'/usr/bin/ld: test.cpp:(.text+0xd0): undefined reference to `eglChooseConfig'/usr/bin/ld: test.cpp:(.text+0x125): undefined reference to `eglCreateContext'/usr/bin/ld: test.cpp:(.text+0x19c): undefined reference to `eglCreatePbufferSurface'/usr/bin/ld: test.cpp:(.text+0x1ee): undefined reference to `eglMakeCurrent'collect2: error: ld returned 1 exit status

How can I fix the issue?

#include <EGL/egl.h>#include <iostream>int main() {    EGLDisplay display;    EGLConfig config;    EGLContext context;    EGLSurface surface;    EGLint num_config;    // Get Display    display = eglGetDisplay(EGL_DEFAULT_DISPLAY);    if (display == EGL_NO_DISPLAY) {        std::cout << "Failed to get EGL display." << std::endl;        return -1;    }    // Initialize EGL    if (!eglInitialize(display, 0, 0)) {        std::cout << "Failed to initialize EGL." << std::endl;        return -1;    }    // Get Config    if (!eglChooseConfig(display, NULL, &config, 1, &num_config)) {        std::cout << "Failed to choose config." << std::endl;        return -1;    }    // Create Context    context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);    if (context == EGL_NO_CONTEXT) {        std::cout << "Failed to create EGL context." << std::endl;        return -1;    }    // Create a Pbuffer surface.    const EGLint pbufferAttributes[] = {        EGL_WIDTH, 10,        EGL_HEIGHT, 10,        EGL_NONE,    };    surface = eglCreatePbufferSurface(display, config, pbufferAttributes);    if (surface == EGL_NO_SURFACE) {        std::cout << "Failed to create EGL surface." << std::endl;        return -1;    }    // Make the context current    if (!eglMakeCurrent(display, surface, surface, context)) {        std::cout << "Failed to make context current." << std::endl;        return -1;    }    std::cout << "EGL initialization successful." << std::endl;    return 0;}

Viewing all articles
Browse latest Browse all 7069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>