Failures compiling GLSL after porting from linux to windows (glew, glfw3)

Hello, I have been stumped on this for a while so I thought I would see if anyone here could lend assistance. I have an OpenGL app which I built and have had no difficulties compiling and running on my Linux desktop (running Debian 9), but when I moved the source to my Windows 10 laptop to try a Windows build, I started having difficulties. The app uses GLEW to load GL, and GLFW3 for window management. So after some research and experimenting, I ended up with a MinGW build which would actually compile. The problem is that when the program runs, it fails to create the shaders even using the same code that worked on Linux. What’s super strange, though, is the actual error log for the compilation doesn’t show anything. In development, when there have been syntax errors in my shaders I will get an info log message, and the same thing happened when I deliberately inserted an error into the shaders here, too. But it seems that all that’s coming back is an empty C string, so what gives? It doesn’t seem like the problem is with my GLSL, so either its with my source, some aspect of the linking of GLEW, or hardware/driver incompatibilities.

The specs of the computer where I’m having issues: HP Spectre x360, i7 dual-core, with Intel HD 5500. I believe the driver is manufacturer specific to HP, at least that’s what the Intel site said. I would find it hard to believe that it can’t handle OpenGL 3.3, though, which is what I’m asking for. Moreover, it doesn’t complain about failing to create the context, which is what happens in SSH and what I would expect if OpenGL were really not available.

Here’s some of the code I’m dealing with, in case something here would work on Linux but break on Windows:
The code to initialize the program and build the context:

// Initialize GLFW
    if(!glfwInit()) {
        fprintf(stderr, "ERROR: Failed to initialize GLFW.
");
        return false;
    }
    // Ask for a context OpenGL 3.2 or higher
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    window_ = glfwCreateWindow(window_w, window_h, Settings::WINDOW_TITLE, 0, 0);
    // Make sure we successfully created a window with the desired
    //  OpenGL context version
    if(!window_) {
        fprintf(stderr, "ERROR: Failed to create OpenGL context.
");
        return false;
    }
    glfwMakeContextCurrent(window_);
    glfwSwapInterval(1);
    // Load GL libraries with GLEW
    glewExperimental = true;
    if(glewInit()!=GLEW_OK) {
        fprintf(stderr, "ERROR: Could not load GL libraries.
");
        glfwDestroyWindow(window_);
        glfwTerminate();
        window_ = 0;
        return false;
    }

Here’s the shader compilation: (only a snippet, but the output suggests the code doesn’t get past this point for any of the shaders)

 // compile and check vertex shader
    int infoLogLength;
    char const * vertexSourcePointer = vertexShaderCode.c_str();
    glShaderSource(vertexShaderId, 1, &vertexSourcePointer, NULL);
    glCompileShader(vertexShaderId);
    glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infoLogLength);
    if(infoLogLength > 0){
        std::vector<char> errorMessage(infoLogLength+1);
        glGetShaderInfoLog(vertexShaderId, infoLogLength, NULL, &errorMessage[0]);
        fprintf(stderr, "ERROR: Vertex shader compile failed: %s
", &errorMessage[0]);
        return false;
    }

And here’s a sample vertex shader, which fails to compile:

#version 330

layout(location=0) in vec2 vertex;
layout(location=1) in vec2 vertex_uv;

// matrix setup
uniform mat4 proj;

out vec2 tex_coords;

void main() {
    gl_Position = proj * vec4(vertex, 0.0, 1.0);
    tex_coords = vertex_uv;
}

I definitely don’t see why this should be happening. If anyone has any thoughts, needs clarification, please feel free.
Newline termination issue? Wouldn’t that be hilarious.:doh:

[QUOTE=vinkna;1293031]Here’s the shader compilation: (only a snippet, but the output suggests the code doesn’t get past this point for any of the shaders)


    glCompileShader(vertexShaderId);
    glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infoLogLength);
    if(infoLogLength > 0){
        std::vector<char> errorMessage(infoLogLength+1);
        glGetShaderInfoLog(vertexShaderId, infoLogLength, NULL, &errorMessage[0]);
        fprintf(stderr, "ERROR: Vertex shader compile failed: %s
", &errorMessage[0]);
        return false;
    }

[/QUOTE]
You should be using glGetShaderiv(GL_COMPILE_STATUS) to determine whether there was actually an error. A successful compile can still result in a non-zero log length, e.g. due to warnings. Or for no reason at all; nothing in the standard requires successful compilation to produce a zero-length log. It’s conceivable (and legitimate) for a driver to always makes the log length non-zero just to avoid potential issues with client code allocating zero bytes of memory for the log (e.g. malloc(0) may return NULL or it may return a valid pointer).

Oof, you’re right. Thanks, the shaders are loading correctly now.