简体   繁体   中英

Program won't run when there's any function from the GLEW library (C++)

I have reinstalled windows for other reasons, and after setting up MinGWx64 (my portable compiler of choice), I had it working back again, EXCEPT for a little problem; I tried to compile an old project with OpenGL (using GLFW ), and it did it with no exceptions nor errors; but then I tried to run the code, and I just couldn't. No errors, no waiting, nothing, just stopped instantly. So I made some tests, and long story short, it was GLEW . Basically, if you invoke any function from GLEW , the program just won't run, no matter the line from where it is called, but will previously compile without any issues (that have to be with the library I mean).

This is a short example of what that looks like:

#include <iostream>
#include <GL/gl.h>

int main() {
    std::cout << "works\n";
    glfwInit();
    return 0;
};

This works, but now when I add a glew function (those some-variables would be values):


#include <iostream>
#include <GL/glew.h> //Included before (correctly)
#include <GL/gl.h>

int main() {
    std::cout << "works\n";
    glfwInit();

    GLFWwindow* window = glfwCreateWindow((someresulution),(someresolution),(sometitle),NULL,NULL);

    glfwMakeContextCurrent(window);
    if (glewInit()!=GLEW_OK) std::cout << "glew not ok\n"; //HERE

    return 0;
};

Again, it compiles just fine, but the program won't do anything (even tho the function call is below the "works" log, but neither it or "glew not ok" will be logged), just exit instantly.

This leads me to think it is something to be with the linking, maybe it not finding glew32.lib , but I have checked all files were in the right dirs like 4 times. The path's ok, vscode settings are ok (if that helps anyway), and I just can't figure it out, as it is the first time something like this happens to me. If there's anyone that knows about a solution or something about it, I would be pleased to have some help, any suggestions will be appreciated. Thanks.

Did you define GLEW_STATIC for static version or GLEW_BUILD for dll version in your program ?? I guess without defining those will create compilation errors in glew

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM