How to get started with OpenGL on Linux with C++?

Hi,
I have tried running a 1st OpenGL program and receive the error: Permission denied.

  1. To setup OpenGL with Linux Mint Mate I:
    Linux > Terminal > (go to folder to store new file. E.g.: /media/All files) > touch BasicGLUT.cpp > nano BasicGLUT.cpp > (enter code and save file) > g++ BasicGLUT.cpp -o BasicGlut -lglut -lGL > ./BasicGlut > Permission denied.
    I also tried g++ BasicGLUT.cpp -lGL -lGLU -lglut -lm -o BasicGlut > Permission denied.

  2. To setup OpenGL with Linux Mint Mate with NetBeans 7.3 with C++ I:
    Install OpenGL to Linux: url
    Linux > Terminal > sudo apt-get update
    Linux > Terminal > sudo apt-get install libgl1-mesa-dev
    Linux > Terminal > sudo apt-get update
    Linux > Terminal > sudo apt-get install build-essential
    Linux > Terminal > sudo apt-get install libglew1.5-dev freeglut3-dev libglm-dev
    glxinfo | grep OpenGL

Install NetBeans: url
Download NetBeans: url
Download > Terminal > go to Downloads folder with the downloaded Netbeans file > chmod +x netbeans-7.3-linux.sh > ./netbeans-7.3-linux.sh > netbeans.

NetBeans has problems like:
Mouse click doesn’t hold submenu’s from ribbon menu like File etc…
Compile gives errors:
make[2]: *** [dist/Debug/GNU-Linux-x86/text_book_page_46] Error 1
make[2]: Leaving directory /media/All files/Text book page 46' make[1]: *** [.build-conf] Error 2 make[1]: Leaving directory /media/All files/Text book page 46’
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 375ms)

Here is my code I’m using:


// #include <GL/GLUT.h> // Might need to change this for Linux, as this example is for a Mac.
#include <GL/gl.h>
#include <GL/glut.h>

void render(void);

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100, 100);
    glutInitWindowSize(640, 480);
    glutCreateWindow("Simple GLUT application");

    glutDisplayFunc(render);

    glutMainLoop(); // Says process has finished and can start rendering.
}

void render(void)
{

}

Please use [noparse]

...

or

...

[/noparse] blocks around your code and terminal output. Makes it easier to read. Added that for you.

I took your code, and it compiled and ran just fine here with GCC and NVidia drivers, using the exact same command line you did.

So I’d wager you’re probably trying to compile and run the executable on a DOS or Windows disk partition, not a Linux partition. If so, compile your program to write the executable in /tmp, $HOME, or somewhere on a Linux partition, and then run it from there.

Assuming that works, see these link for details on how you can permit execution of Linux binaries on DOS/Windows partitions:

In particular, try mount -o remount,exec /win/c (as root) for testing.

[QUOTE=Dark Photon;1248639]Please use [noparse]

...

or

...

[/noparse] blocks around your code and terminal output. Makes it easier to read. Added that for you.

I took your code, and it compiled and ran just fine here with GCC and NVidia drivers, using the exact same command line you did.

So I’d wager you’re probably trying to compile and run the executable on a DOS or Windows disk partition, not a Linux partition. If so, compile your program to write the executable in /tmp, $HOME, or somewhere on a Linux partition, and then run it from there.

Assuming that works, see these link for details on how you can permit execution of Linux binaries on DOS/Windows partitions:

In particular, try mount -o remount,exec /win/c (as root) for testing.[/QUOTE]

Thanks for your reply.

  1. Noted re
 

.

  1. The code works in the /temp file, although I think it’s supposed to show a blank window, however it shows a window with the Terminal data I typed to run the OpenGL window?

  2. I looked at your two links and tried the 1st link.
    I went to Terminal > etc > sudo nano fstab > password: x… > (delete noexec) > Ctrl-o > Enter > Ctrl-x.
    I went to Terminal > etc > sudo mount -o remount,exec /win/c
    I received the error: mount: can’t find /win/c in /etc/fstab or /etc/mtab

  3. I also tried Terminal > (folder with BasicGLUT.cpp in my disk partition) > sudo mount -o remount,exec /win/c and receive the same error:
    mount: can’t find /win/c in /etc/fstab or /etc/mtab.

I don’t think I understand the /win/c properly. Is this meant to be a file path to somewhere else?

Your redraw function is empty. So all it does is create a window. It doesn’t actually do anything when told to redraw the window. Add this to your render() function:


void render(void)
{
  glClearColor( 0,0,1,1 );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  glutSwapBuffers();
}

  1. I looked at your two links and tried the 1st link.
    I went to Terminal > etc > sudo nano fstab > password: x… > (delete noexec) > Ctrl-o > Enter > Ctrl-x.
    I went to Terminal > etc > sudo mount -o remount,exec /win/c
    I received the error: mount: can’t find /win/c in /etc/fstab or /etc/mtab

Substitude the path to your VFAT/NTFS/whatever mount point in for /win/c.

mount -l will show your current mount points. Or just look at /etc/fstab for the list activated on boot. It’ll have the same base path as where you were trying to compile and run your program before.

Same answer for #4.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.