GLFW 3 initialized, yet not?
Asked Answered
F

2

8

I'm struggling with creating a window with the GLFW 3 function, glfwCreateWindow. I have set an error callback function, that pretty much just prints out the error number and description, and according to that the GLFW library have not been initialized, even though the glfwInit function just returned success?

Here's an outtake from my code

// 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;
}

And here's what's printed out in the console

INITIALIZER: GLFW Initialized succesfully!
65537    The GLFW library is not initialized
INITIALIZER: Failed to create window!

I think I'm getting the error because of the setup isn't entirely correct, but I've done the best I can with what I could find around the place

I downloaded the windows 32 from glfw.org and stuck the 2 includes files from it into minGW/include/GLFW, the 2 .a files (from the lib-mingw folder) into minGW/lib and the dll, also from the lib-mingw folder, into Windows/System32

In code::blocks I have, from build options -> linker settings, linked the 2 .a files from the download. I believe I need to link more things, but I can figure out what, or where I should get those things from.

Fokine answered 29/6, 2013 at 15:33 Comment(0)
F
4

I tried reinstalling codeblocks and mingw, which solved the issue.

Seems like GLFW3 doesn't like having previous versions installed at the same time for some reason, so if anyone else is having a similar problem, you might want to try that.

Fokine answered 3/7, 2013 at 16:51 Comment(1)
This sort of thing happens when you put DLLs in System32. Do not do that, distribute them with your application and leave the system directories untouched.Information
L
1

I experienced similar problems in Cocos 3.8.1 and 3.10. I have never installed codeblocks or mingw, so it did not make sense to install them for me.

The GLFW.lib file in the cocos directory is out of date.

http://www.glfw.org/download.html, and replace the lib file in your project with the latest one, and it may resolve your error.

Longwinded answered 15/4, 2016 at 18:56 Comment(1)
I'm running into the same problem, is there any more info you can add? Which file did you need to replace, and did you do anything after, like rebuild everything etc? Replacing cocos2d\external\glfw3\prebuilt\win32\glfw3.lib doesn't seem to do it, on top of replacing the ones in my output dirs.Upstart

© 2022 - 2024 — McMap. All rights reserved.