C++;使用GLFW调用时出错 最近我一直在学习C++程序,但是在使用GLW和GLFW时,我遇到了一个问题。

C++;使用GLFW调用时出错 最近我一直在学习C++程序,但是在使用GLW和GLFW时,我遇到了一个问题。,c++,glfw,C++,Glfw,来源(.cpp): 编辑2: 以下是我目前的代码: #define GLEW_STATIC #include "GLEW/glew.h" #include <GLFW/glfw3.h> #include <iostream> int main(){ std::cout<<"test" << std::endl; glfwInit(); GLFWwindow* window; window = glfwCreate

来源(.cpp):

编辑2: 以下是我目前的代码:

#define GLEW_STATIC
#include "GLEW/glew.h"
#include <GLFW/glfw3.h>
#include <iostream>

int main(){
    std::cout<<"test" << std::endl;
    glfwInit();

    GLFWwindow* window;
    window = glfwCreateWindow(800,600,"TEST", NULL, NULL);

    glfwShowWindow(window);
    while(!glfwWindowShouldClose(window))glfwPollEvents();
    glfwDestroyWindow(window);
    glfwTerminate();
    std::cin.get();
}
#定义GLEW#U静态
#包括“GLEW/GLEW.h”
#包括
#包括
int main(){

std::cout在
stdout
上没有输出的一些原因:

  • 如果您在Windows上运行,则您的程序可能已在Windows子系统中编译。然后,对
    stdout
    的任何打印都将转到bitbucket。如果您使用的是MinGW工具链,则这由
    -mwindows
    链接器标志控制
  • 如果程序崩溃,则缓冲输出可能无法写入。因此,在执行任何其他操作之前,请尝试刷新输出流。请注意,程序可能会无声地崩溃
您可以询问以下事项以了解更多信息:

  • 使用编译器附带的调试器单步执行代码时会发生什么情况
  • 由于
    glfwCreateWindow
    隐藏了输出,可能它在该函数中崩溃。您传递了正确的参数吗
  • glfwCreateWindow
    是否返回有效指针

将程序输出重定向到一个文件。听起来你只是在与终端模拟器之间产生误解,而不是用C++。尝试用换行符结束输出。你可能只是没有注意到输出,因为它与你的提示在同一行。STD::CouToul,调用必要的代码来结束<代码> GLFW gram:
glfweterminate()
@mr5看起来程序一开始甚至都没有执行main()方法。我做了一些编辑,可能会更深入地了解这个问题
glfwShowWindow(window);
while(!glfwWindowShouldClose(window))glfwPollEvents();
glfwDestroyWindow(window);
#define GLEW_STATIC
#include "GLEW/glew.h"
#include <GLFW/glfw3.h>
#include <iostream>

int main(){
    std::cout<<"test" << std::endl;
    glfwInit();

    GLFWwindow* window;
    window = glfwCreateWindow(800,600,"TEST", NULL, NULL);

    glfwShowWindow(window);
    while(!glfwWindowShouldClose(window))glfwPollEvents();
    glfwDestroyWindow(window);
    glfwTerminate();
    std::cin.get();
}
int main(){
    std::cout<<"test" << std::endl;

    std::cout.flush();

    std::cin.get();
}
void test(){
    glfwInit();

    GLFWwindow* window;
    window = glfwCreateWindow(800,600,"TEST", NULL, NULL);

    glfwShowWindow(window);
    while(!glfwWindowShouldClose(window))glfwPollEvents();
    glfwDestroyWindow(window);
    glfwTerminate();

}