Sorry for the boring topic. I'm writing a side project for fun using Glew and 
Glfw. And I encounter an external compiler error.

A test file who reproduces the error.
    
    
    const
        GLFW_CONTEXT_VERSION_MAJOR = 0x00022002
        GLFW_CONTEXT_VERSION_MINOR = 0x00022003
        GLFW_OPENGL_PROFILE = 0x00022008
        GLFW_OPENGL_CORE_PROFILE = 0x00032001
    
    proc glfwInit*():cint {.header: "GLFW/glfw3.h".}
    
    proc glfwCreateWindow*(width, height:int, title:cstring = "GLFW Window", 
monitor:pointer = nil,
        share:pointer = nil):pointer {.header: "GLFW/glfw3.h".}
    
    proc glfwMakeContextCurrent*(window:pointer) {.header: "GLFW/glfw3.h".}
    
    proc glfwSwapInterval*(interval:int) {.header: "GLFW/glfw3.h".}
    
    proc glfwSwapBuffers*(window:pointer) {.header: "GLFW/glfw3.h".}
    
    proc glfwPollEvents*() {.header: "GLFW/glfw3.h".}
    
    proc glfwWindowShouldClose*(window:pointer):cint {.header: "GLFW/glfw3.h".}
    
    proc glfwDestroyWindow*(window:pointer) {.header: "GLFW/glfw3.h".}
    
    proc glfwTerminate*() {.header: "GLFW/glfw3.h".}
    
    proc glfwWindowHint(hint:int, value:int) {.header: "GLFW/glfw3.h".}
    
    proc glewInit():char {.header:"GL/glew.h".}
    
    proc glewGetErrorString(err:char):cstring {.header:"GL/glew.h".}
    
    
###############################################################################
    
    
    var glfwErr = glfwInit()
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3)
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3)
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE)
    var winHandle = glfwCreateWindow(640, 480)
    glfwMakeContextCurrent(winHandle)
    
    var glewErr = glewInit()
    echo glewGetErrorString(glewErr)
    
    while bool(glfwWindowShouldClose(winHandle)) == false:
        glfwSwapBuffers(winHandle)
        glfwPollEvents()
    
    glfwDestroyWindow(winHandle)
    glfwTerminate()
    
    
    
    Run

The command
    
    
    nim c --passL:'`pkg-config glew --static --cflags --libs`' 
--passL:'`pkg-config glfw3 --static --cflags --libs`'  test.nim
    
    
    
    Run

The error
    
    
    Error: execution of an external compiler program 'gcc -c  -w -I 
../Src/GlLoader/Glad  -I/home/drit0/Programmes/Nim/nim-0.19.0/lib -o 
/home/drit0/.cache/nim/test_d/test.c.o /home/drit0/.cache/nim/test_d/test.c' 
failed with exit code: 1
    
    In file included from /home/drit0/.cache/nim/test_d/test.c:12:
    /usr/include/GL/glew.h:85:2: error: #error gl.h included before glew.h
     #error gl.h included before glew.h
      ^~~~~
    /usr/include/GL/glew.h:97:2: error: #error glext.h included before glew.h
     #error glext.h included before glew.h
      ^~~~~
    
    
    
    Run

How the hell it is possible to include gl twice here ? In glew there is a flag 
called "glewExperimental" and I would try to set it to true but I don't know 
how to import that in Nim. 

Reply via email to