Search code examples
c++openglglfwglew

Application silently crashes at glfwCreateWindow()


I am making a C++ application using GLFW/GLEW for windowing and graphics:

#include <GLEW/glew.h>
#include <GLFW/glfw3.h>

int main()
{
    // init glfw
    if (!glfwInit())
    {
        std::cout << "GLFW init failed!: " << std::endl;
    }
    // set up window hints
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    // APP FAILS ON THIS LINE
    GLFWwindow* window = glfwCreateWindow(320, 180, "Test Window!", NULL, NULL);
    // verify window is valid
    if (window == NULL)
    {
        std::cout << "Failded to create GLFW window" << std::endl;
        glfwTerminate();
        std::cin.get();
    }
    glfwMakeContextCurrent(window);

    // init GLEW now that we have a current context (window)
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        std::cout << "Failed to init GLEW: " << glewGetErrorString(err) << std::endl;
        abort();
    }
}

This works perfectly on my system, but I am trying to distribute it to my friend since I will eventually like to share this app. I am using visual studio's guide on distributing, and it has the needed dlls to function on my friends machine. However, in my initialize function, the app is killed without a glfw error callback or anything.

My friend's machine is a windows 10 laptop, with Intel UHD Graphics 620. The installed opengl version is 4.5.

I have tried verifying the installed opengl version, which is higher than what my application requests.

I have tried checking if any missing dlls are not present in my app using Dependencies and Dependency Walker, all of which show nothing is amiss.

I set the GLFW error callback to spam console if there is a problem, and it is not called at all during the runtime on my friends computer.

Edit: I had another person test the code, they also see the same issue. I dont think this is a system issue.


Solution

  • Solved. I was building this in Visual Studio under Debug configuration, so it was trying to use the VC++ debug runtime libraries when shared with others. Rebuilding my libraries and application for Release fixed the issue.