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 5 of 5

Thread: Help me linking OpenGl using g++

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2015
    Posts
    18

    Question Help me linking OpenGl using g++

    Code :
    #include <glew.h>
     
     
    int main(){
     
        return 0;
    }

    I'm trying to compile this .cpp file with g++.

    this is what I did.

    Code :
    g++ -std=c++11 main.cpp -I/include/GL


    but I'm getting an error that says "no such file: glew.h".


    How do you guys compile OpenGL with g++? thanks.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,420
    Quote Originally Posted by yj1214 View Post
    Code :
    #include <glew.h>
     
    int main(){
        return 0;
    }
     
    g++ -std=c++11 main.cpp -I/include/GL
    but I'm getting an error that says "no such file: glew.h". How do you guys compile OpenGL with g++? thanks.
    You're doing it right. The issue is probably that your system doesn't have the GLEW header files installed. Typically, headers are in a "*-devel" package.

    For example, GLEW headers would be in a separate "glew-devel" package, where as the glew library itself is in the "glew" package. Here:

    Code :
    > ls /usr/include/GL/glew.h
    /usr/include/GL/glew.h
     
    > rpm -qf /usr/include/GL/glew.h
    glew-devel-1.9.0-5.1.2.x86_64

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2015
    Posts
    18
    I'm sorry but I don't know what -DEVEL is. In my directory, I have these.

    Code :
    include
    lib
    glew32.dll
    SDL2.dll
    main.cpp

    My glew.h is in the include folder. So I can type g++ -I/include/GL

    or do I have to do something else?

  4. #4
    Member Regular Contributor
    Join Date
    Dec 2009
    Posts
    251
    try -I./include/GL (notice the "." before the first "/")

  5. #5
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,420
    Right. Or -Iinclude/GL. You may also need to change #include <glew.h> to #include "glew.h" as well. <> means to look in the system include directories, and "" means to look in user-specified directories (basically), though the <> is up to the compiler.

    Typically headers like glew.h would be installed system-wide in system include directories, so you'd use <>. But you're not doing that.

Posting Permissions

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