Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

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

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2013
    Posts
    3

    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:

    Code cpp:
    // #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)
    {
     
    }
    Last edited by Dark Photon; 03-02-2013 at 07:57 AM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,194
    Please use [highlight=cpp]...[/highlight] or [code]...[code] 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:

    * http://stackoverflow.com/questions/4...n-ubuntu-10-10
    * http://stackoverflow.com/questions/1...ntfs-partition

    In particular, try mount -o remount,exec /win/c (as root) for testing.
    Last edited by Dark Photon; 03-02-2013 at 08:25 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2013
    Posts
    3
    Quote Originally Posted by Dark Photon View Post
    Please use [highlight=cpp]...[/highlight] or [code]...[code] 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.

    Thanks for your reply.
    1. Noted re [code] [code].

    2. 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?

    3. 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

    4. 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?

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,194
    Quote Originally Posted by eiger3970 View Post
    2. 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?
    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:

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

    3. 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •