简体   繁体   English

当有来自 GLEW 库 (C++) 的任何函数时,程序将不会运行

[英]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;由于其他原因,我重新安装了 Windows,并且在设置了MinGWx64 (我选择的便携式编译器)后,它又恢复了,除了一个小问题; I tried to compile an old project with OpenGL (using GLFW ), and it did it with no exceptions nor errors;我试图用OpenGL (使用GLFW )编译一个旧项目,它没有例外也没有错误; 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 .所以我做了一些测试,长话短说,它是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).基本上,如果您从GLEW调用任何函数,该程序将不会运行,无论它是从哪里调用的行,但之前编译时不会出现任何问题(我的意思是必须与库有关)。

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):这有效,但现在当我添加一个glew函数时(那些变量将是值):


#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.同样,它编译得很好,但程序不会做任何事情(即使函数调用低于“工作”日志,但它或“glew not ok”都不会被记录),只是立即退出。

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.这让我认为这与链接有关,也许它没有找到glew32.lib ,但我已经检查了所有文件都在正确的目录中,例如 4 次。 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.路径没问题,vscode 设置没问题(如果这有帮助的话),我就是想不通,因为这是我第一次遇到这样的事情。 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 ??你定义GLEW_STATIC静态版本或GLEW_BUILD在你的程序DLL版本? I guess without defining those will create compilation errors in glew我猜不定义这些会在glew中产生编译错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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