Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ GLFW 3已初始化,但尚未初始化?_C++_Opengl_Glfw - Fatal编程技术网

C++ GLFW 3已初始化,但尚未初始化?

C++ GLFW 3已初始化,但尚未初始化?,c++,opengl,glfw,C++,Opengl,Glfw,我正在努力用GLFW3函数创建一个窗口,glfwCreateWindow。 我已经设置了一个错误回调函数,它几乎只是打印出错误号和描述,根据这个函数,GLFW库还没有初始化,即使glfwInit函数刚刚返回success 这是我代码的一部分 // Error callback function prints out any errors from GFLW to the console static void error_callback( int error, const char *desc

我正在努力用GLFW3函数创建一个窗口,glfwCreateWindow。 我已经设置了一个错误回调函数,它几乎只是打印出错误号和描述,根据这个函数,GLFW库还没有初始化,即使glfwInit函数刚刚返回success

这是我代码的一部分

// Error callback function prints out any errors from GFLW to the console
static void error_callback( int error, const char *description )
{
    cout << error << '\t' << description << endl;
}


bool Base::Init()
{
    // Set error callback
    /*!
     *  According to the documentation this can be use before glfwInit,
     *  and removing won't change anything anyway
     */
    glfwSetErrorCallback( error_callback );



    // Initialize GLFW
    /*!
     *  This return succesfull, but...
     */ 
    if( !glfwInit() )
    {
        cout << "INITIALIZER: Failed to initialize GLFW!" << endl;
        return false;
    }
    else
    {
        cout << "INITIALIZER: GLFW Initialized successfully!" << endl;
    }



    // Create window
    /*!
     *  When this  is called, or any other glfw functions, I get a
     *  "65537    The GLFW library is not initialized" in the console, through
     *  the error_callback function
     */
    window = glfwCreateWindow( 800,
                               600,
                               "GLFW Window",
                               NULL,
                               NULL );


    if( !window )
    {
        cout << "INITIALIZER: Failed to create window!" << endl;
        glfwTerminate();
        return false;
    }


    // Set window to current context
    glfwMakeContextCurrent( window );


    ...


    return true;
}
我想我是因为设置不完全正确而出错的,但我已经尽了最大努力在这个地方找到了我能找到的

我从glfw.org下载了windows 32,并将其中的2个include文件粘贴到minGW/include/glfw中,将2.a文件(从lib minGW文件夹)粘贴到minGW/lib中,将dll(也从lib minGW文件夹)粘贴到windows/System32中


在代码::blocks中,我从buildoptions->linker settings链接了下载的2.a文件。我相信我需要链接更多的东西,但我可以弄清楚我应该从何处获得这些东西。

我尝试重新安装codeblocks和mingw,解决了这个问题


由于某种原因,GLFW3似乎不喜欢同时安装以前的版本,因此如果其他人有类似的问题,您可能想尝试一下。

我在Cocos 3.8.1和3.10中遇到过类似的问题。 我从未安装过代码块或mingw,所以为我安装它们是没有意义的

cocos目录中的GLFW.lib文件已过期


,并用最新的lib文件替换项目中的lib文件,这可能会解决您的错误。

将DLL放入
System32
时会发生这种情况。不要这样做,将它们与您的应用程序一起分发,并保持系统目录不变。我遇到了相同的问题,您是否可以添加更多信息?你需要替换哪个文件,之后你做了什么,比如重建所有东西等等?替换
cocos2d\external\glfw3\prebuild\win32\glfw3.lib
除了替换我的输出目录中的文件外,似乎还不能做到这一点。
INITIALIZER: GLFW Initialized succesfully!
65537    The GLFW library is not initialized
INITIALIZER: Failed to create window!