skip to Main Content

So i want to experimenting with the jextract tool and the Foreign Function and Memory API on OpenGL but im having bad time resolving java.lang.UnsatisfiedLinkError: unresolved symbol: glutInit. It seems like the JVM cannot locate the binaries of the OpenGL library to link the method.I know that you load libraries with the System.load method but the problem is i do not which binaries i must load. The jextract tool is pointed against the .h files and works as expected

`

System.load("/usr/lib/x86_64-linux-gnu/libOpenGL.so.0"); // loads fine but the error persists


try (var s = MemorySession.openConfined()) {
    MemorySegment arc = s.allocate(ValueLayout.JAVA_INT, 0);
    glutInit(arc, arc);
    glutInitDisplayMode(GLUT_SINGLE());
    glutInitWindowSize(400, 300);
    glutInitWindowPosition(100, 100);
    glutCreateWindow(s.allocateUtf8String("Hello World!"));
    MemorySegment callBack = allocate(OpenGLLauncher::displayMe, s);
    glutDisplayFunc(callBack);
    glutMainLoop();
}

`

I assume that i need to load a .so file (im using ubuntu) so i tried manually locating the .so file in /usr/lib i tryied a bunch of them and nothing worked out. I tried searching but nothing was suitable for my case. Here is few thing i tried to follow:
1
2

2

Answers


  1. Chosen as BEST ANSWER

    It seems like you do not need to know the exact .so file, but the library name

    I used:

    System.loadLibrary("GLU"); System.loadLibrary("GL"); System.loadLibrary("glut");
    

    And it worked


  2. You could have a look to project Panama-GL that uses Panama to enable OpenGL for Java. You probably can find a couple of recipes for 3D rendering and Panama configuration there (the issue board provides a kind of Q&A on this, keeping track on former hard bug resolution).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search