glfwInit failing error

Member
Posts: 227
Joined: 2008.08
Post: #1
So, I've had this error for a while and I had found a similar thread with a similar problem.

[Session started at 2008-08-23 11:15:36 -0400.]
glfwInit failing because you aren't linked to OpenGL
FAILED OPENING WINDOW
O3D has exited with status 1.

However after reading the thread I added a resource folder and I still got the same problem on OSX tiger.

Heres the code:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <GL/glfw.h>

void render(void){
    glClear(GL_COLOR_BUFFER_BIT);
    
    glBegin(GL_TRIANGLES);
        glVertex3i(1,1,1);
        glVertex3i(1,1,1);
        glVertex3i(1,0,1);
    glEnd();
    
    glFlush();
    glfwSwapBuffers();
    return;
}
int main(void){
    int     width, height;
    float aspect;
    glfwInit();
    atexit(glfwTerminate);
    
    glfwEnable( GLFW_STICKY_KEYS );
    glfwSwapInterval( 0 );
    
    if(!glfwOpenWindow(640,480,8,8,8,8,8,8,GLFW_WINDOW)){
        printf("FAILED OPENING WINDOW");
        glfwTerminate();
        exit(1);
    }
    
    glfwGetWindowSize( &width, &height );
    height = height > 0 ? height : 1;
    glViewport( 0, 0, width, height );
    
    glMatrixMode(GL_PROJECTION);
    
        glLoadIdentity();
        aspect_ratio = ((float)height) / width;
        glFrustum(.5, -.5, -.5 * aspect, .5 * aspect, 1, 50);
        
    glMatrixMode(GL_MODELVIEW);
    
    glfwSetWindowTitle("O3D WINDOW TEST");
    //glClearColor(1,1,1,1);
    while(1){
        render();
        if (glfwGetKey(GLFW_KEY_ESC))  exit(0);
    }
    
}

Any help would help.

ps Don't suggest sdl or glut, I have my reasons.
pss I didn't post in that thread as most forums don't like reviving old threads.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
Oddity007 Wrote:glfwInit failing because you aren't linked to OpenGL

Assuming this means what it says, try adding OpenGL.framework to your project.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #3
I already have it in, thats what makes it frustrating.
[Image: lol.gif]

This is my xcode project
[Image: xcode3dbd9.png]
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Line 135 of macosx_init.c
http://glfw.svn.sourceforge.net/viewvc/g...iew=markup

I wrote this code, and I don't see how it can fail if you're linked to OpenGL, and I've never met anyone else with the issue. I have to assume that (despite appearances) you are not linked to OpenGL. Please post the detailed build log from Xcode to confirm that you are indeed managing to link to the OpenGL framework.

The current implementation of GLFW for Mac OS X is Carbon. I'd avoid it. I can't think of any good reason to use GLFW over SDL other than deployed binary size.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #5
Nothing but build succeeded.
I won't use sdl as I can't use argc and argv.
The file size also has an impact for the systems I am developing for.
[Image: my.php?image=screenshotuw1.png]
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
Why can't you use argc and argv with SDL?!

You need to make clean, then build again.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #7
I fixed the problem by putting the framework includes in the prefix header.
Now it's making the window from a nib and returns 48 if I delete it.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
Oddity007 Wrote:I fixed the problem by putting the framework includes in the prefix header.

There's no way that could have any effect.

Quote:Now it's making the window from a nib and returns 48 if I delete it.

What do you mean?
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #9
It makes the window from a main.nib for some reason.
Then, if I delete the nib, it returns a strange error code of 48.
How do I disable using a nib in xcode 2.4, google keeps giving stuff for 3.0
edit:Actually if you could supply a sample xcode 2.4 project, that would help me figure out what I'm doing wrong.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
GLFW does not use a nib, cannot use a nib. What are you talking about?
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #11
Okay its obvious that my mac hates me, so if possible could someone tell me where I can find a sample xcode 2.4 project, as google is being surprisingly mute.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
/Developer/Examples is full of 'em... just not for GLFW. For GLFW, I'd start with an empty project, add a "Carbon Application" target, the GLFW library and header, the OpenGL and Carbon frameworks.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #13
Did that, and now for the inescapable error:
[Image: my.php?image=screenshotfc5.png]
P.S. You forgot AGL, or is that not needed?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #14
AGL is probably also required.

Your picture link is broken (needs to be a link, not an inline image, with imageshack).

Cmd-shift-3 is an easier way to take screenshots than some random 3rd-party software Rasp

I can't tell anything much at all from the screenshot, but if your app compiles and links, chances are it's a bug in your program.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #15
Well I have it in there.
Its my own screenshot taker, ha ha.
*sigh* the curse of the messed up glfw.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Help! Build failing on libcurl GolfHacker 7 5,516 Nov 3, 2007 08:03 PM
Last Post: GolfHacker
  Failing to link with static library c0d1f1ed 11 5,424 Sep 24, 2006 05:37 PM
Last Post: c0d1f1ed
  'Unidentified error' error in Xcode scgames 2 3,760 Jun 10, 2006 01:38 AM
Last Post: scgames