www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Building a GLFW app w/ GDC on a Mac

reply Max kaufmann <max.kaufmann gmail.com> writes:
Trying to build this app on a mac:

import glfw;

void main() {
        int running = 1;
        glfwInit();
        if (!glfwOpenWindow(300,300,0,0,0,0,16,0,GLFW_WINDOW)) {
                glfwTerminate();
                return 0;
        }
        glfwSetWindowTitle("GLFW - now in D!");
        glfwSwapInterval(0);
        while( running ) {
                glClear(GL_COLOR_BUFFER_BIT);
                glfwSwapBuffers();
                if (!glfwGetWindowParam(GLFW_OPENED)) {
                        running = 0;
                }
        }
        glfwTerminate();
}

I compiled using this command:

~/gdc/bin/gdc -I ~/src/dlib/ ~/src/dlib/*.d hello.d -lglfw -framework Carbon
-framework AGL -framework OpenGL -o app

Initially ~/src/dlib/glfw.d was giving me compile errors because of two "const"
parameters in line 344 and 347, so I just nixed those type specifiers, and it
compiled fine, however now I'm getting the link error:

/usr/bin/ld: Undefined symbols:
__D2gl7glClearFkZv
collect2: ld returned 1 exit status

When I comment out the call to glClear() the app links fine and when I execute
it I get the window I'd expect, but filled with garbage because there's
nothing's clearing the buffers.

Has anyone else run into this problem?  I've read about people compiling glfw
w/ gdc on a mac fine before, what am I doing wrong?
Oct 20 2007
next sibling parent Johan Granberg <lijat.meREM OVEgmail.com> writes:
Max kaufmann wrote:

 Trying to build this app on a mac:

 Initially ~/src/dlib/glfw.d was giving me compile errors because of two
 "const" parameters in line 344 and 347, so I just nixed those type
 specifiers, and it compiled fine, however now I'm getting the link error:
 
 /usr/bin/ld: Undefined symbols:
 __D2gl7glClearFkZv
 collect2: ld returned 1 exit status

Is glClear in ~/src/dlib/gl.d defined as extern(C)? If not that's probably the problem.
Oct 21 2007
prev sibling next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Max kaufmann wrote:

 Initially ~/src/dlib/glfw.d was giving me compile errors because of two
"const" parameters in line 344 and 347, so I just nixed those type specifiers,
and it compiled fine, however now I'm getting the link error:
 
 /usr/bin/ld: Undefined symbols:
 __D2gl7glClearFkZv
 collect2: ld returned 1 exit status

Seems that you are missing the OpenGL bindings ? You can find OpenGL and GLFW on my home page, along with the little "boing.d" sample program. http://www.algonet.se/~afb/d/ - import gl.glfw; --anders
Oct 21 2007
prev sibling parent Max Kaufmann <max.kaufmann gmail.com> writes:
Figured it out.  Just needed to replace:

version(Win32)
     extern(Windows):
version(linux)
     extern(C):

with

version(Win32)
     extern(Windows):
else
     extern(C):

I'll send a note about it to the GLFW dev guys to about the mod.

Max kaufmann Wrote:

 Trying to build this app on a mac:
 
 import glfw;
 
 void main() {
         int running = 1;
         glfwInit();
         if (!glfwOpenWindow(300,300,0,0,0,0,16,0,GLFW_WINDOW)) {
                 glfwTerminate();
                 return 0;
         }
         glfwSetWindowTitle("GLFW - now in D!");
         glfwSwapInterval(0);
         while( running ) {
                 glClear(GL_COLOR_BUFFER_BIT);
                 glfwSwapBuffers();
                 if (!glfwGetWindowParam(GLFW_OPENED)) {
                         running = 0;
                 }
         }
         glfwTerminate();
 }
 
 I compiled using this command:
 
 ~/gdc/bin/gdc -I ~/src/dlib/ ~/src/dlib/*.d hello.d -lglfw -framework Carbon
-framework AGL -framework OpenGL -o app
 
 Initially ~/src/dlib/glfw.d was giving me compile errors because of two
"const" parameters in line 344 and 347, so I just nixed those type specifiers,
and it compiled fine, however now I'm getting the link error:
 
 /usr/bin/ld: Undefined symbols:
 __D2gl7glClearFkZv
 collect2: ld returned 1 exit status
 
 When I comment out the call to glClear() the app links fine and when I execute
it I get the window I'd expect, but filled with garbage because there's
nothing's clearing the buffers.
 
 Has anyone else run into this problem?  I've read about people compiling glfw
w/ gdc on a mac fine before, what am I doing wrong?

Oct 21 2007