glfwInit causing application to hang

o-and-o wrote on Saturday, April 12, 2014:

I’ve just updated to GLFW3 (Running on MacOSX 10.9). The library built just fine, and the application builds without any errors (it’s a just a main function with glfwInit/Terminate for the time being) but it refuses to launch properly. The sample applications included with GLFW work just fine, but my own application doesn’t, instead the icon just bounces in the dick and never gets any further. Apologies for the sparse details, but as I say, it’s currently just five lines of code refusing to work.

arampl wrote on Saturday, April 12, 2014:

Show your code, please.
EDIT: 99% it’s not os related if samples runs fine.
EDIT2: also check, do you have “return 0;” or “exit(EXIT_SUCCESS);” at the end of main function? (in Linux it does not needed, but who knows)

o-and-o wrote on Saturday, April 12, 2014:

#include <stdio.h>
#include <stdlib.h>
#include "glfw3.h"
int main(int argc, const char * argv[])
{
GLFWwindow* window = NULL;
if(!glfwInit())
{
return 0;
}
glfwTerminate();
return 0;
}

That’s all there is to it.
Edit: Erm, what’s the syntax for posting code around here?

arampl wrote on Saturday, April 12, 2014:

Plain text for syntax, i presume.

Hmm, nothing wrong with the code, it works for me (Xubuntu).
There must be some difference between sample applications and your program.
May be different linkage (static / dynamic)?
May be some project settings different (if you use IDE).
Try to run your program from terminal - helpful messages or warnings may appear.
You can also try to start from one of sample applications, slightly reduce them, compile&run.

arampl wrote on Saturday, April 12, 2014:

Sorry if i’m understood incorrectly, but what do you expect from such program?
It will not create any visible windows, just start and immediately exit.
Same as if source would be just:
int main()
{
return 0;
}

o-and-o wrote on Saturday, April 12, 2014:

I just started using a new version of Xcode today, so it’s entirely possible I’ve got some incorrect linker settings somewhere, I’m going to have to scour them to see if there’s anything noticeably wrong. I was expecting exactly the behaviour you described, but instead it gets stuck initialising GLFW and doesn’t complete. I’ll dig a little deeper and try to determine exactly where it’s failing.

Edit: Ok what I’ve found is that it builds (and then fails to run) when I link the library (which is stored inside the app bundle), but then when I quit Xcode and reopen the project, it claims not to be able to locate the library when building, despite all the paths appearing correct. Still no solution yet though, but it’s looking like an Xcode issue rather than a problem with GLFW itself.

arampl wrote on Tuesday, April 15, 2014:

Hi, OandO.

I’ve found how to insert source code in the posts.
Just use several tildes (i typed seven times) before and after code block. The code will even be highlighted:

#include <glfw.h>

Regards :slight_smile: