Score:1

Ubuntu 20.04 OpenGL error: /usr/bin/ld: cannot find -lG

cn flag

I'm trying to follow this tutorial from 2018:

http://www.codebind.com/linux-tutorials/install-opengl-ubuntu-linux/

I'm under the impression that things must have changed with Ubuntu and configuring OpenGL since these instructions no longer work. In case the article disappears at some point I'll re-iterate all the steps here:

Ubuntu 20.04 install

Verify NVIDIA GPU is properly recognized by Ubuntu, install and configure CUDA (verified works with PyTorch)

Now on to the OpenGL specific stuff:

sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev

enter this program in gedit, save it as main.cpp:

#include <GL/glut.h>

void displayMe(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);
    glVertex3f(0.5, 0.0, 0.5);
    glVertex3f(0.5, 0.0, 0.0);
    glVertex3f(0.0, 0.5, 0.0);
    glVertex3f(0.0, 0.0, 0.5);
    glEnd();
    glFlush();
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE);
    glutInitWindowSize(400, 300);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Hello world!");
    glutDisplayFunc(displayMe);
    glutMainLoop();
    return 0;
}

Compile:

gcc main.cpp -o firstOpenGlApp -lglut -lGLU -lG

Here is the resulting output:

$ gcc main.cpp -o firstOpenGlApp -lglut -lGLU -lG
/usr/bin/ld: cannot find -lG
collect2: error: ld returned 1 exit status

Did something pertaining to configuring OpenGL change since this tutorial was written? What am I missing?

hr flag
You misread (or miscopied) it - the flag should be `-lGL` not `-lG`
cdahms avatar
cn flag
That did it, if you post your response as an answer I'll accept. If you'd rather not bother then I'll post it as an answer myself in a few days, trying to get you the credit though.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.