View mode: basic / threaded / horizontal-split · Log in · Help
March 20, 2005
OS X, gdc and opengl
Hi all, I'm wanting to play with D and openGL on a Mac.  I've managed to 
compile vanilla GCC sources with the GDC patch, and can happily compile 
the example app.
However, I can't figure out how to link against opengl libraries. 
Apple's version of GCC has a -framework option, which GDC and vanilla 
GCC don't recognise.
My next step was to try to compile Apple's GCC tree with the D patches, 
and have run into the following error
../../gcc3/gcc/d/d-lang.cc: In function `bool 
d_mark_addressable(tree_node*)':
../../gcc3/gcc/tree.h:2944: error: too few arguments to function `void 
put_var_into_stack(tree_node*, int)'
../../gcc3/gcc/d/d-lang.cc:898: error: at this point in file
../../gcc3/gcc/d/d-lang.cc: At global scope:
../../gcc3/gcc/d/d-lang.cc:1358: error: invalid conversion from 
`rtx_def*(*)(tree_node*, rtx_def*, machine_mode, int, rtx_def**)' to 
`rtx_def*(*)(tree_node*, rtx_def*, machine_mode, int)'

I don't mind banging my head against the wall to try and fix either of 
these problems, but if someone has already figured it out, well that 
would be nice :)

So,
1) Is there a way to link vanilla gcc+gdc with opengl on Mac OSX?
2) Is there a way around the error I get when compiling Apple's GCC?

Also, I tried to enable --altivec on the vanilla GCC build and the build 
failed due to some "forcecpusubtype_ALL" option missing - am I missing 
something here?

Thanks much
Brad
March 20, 2005
Re: OS X, gdc and opengl
Brad Beveridge wrote:

> Hi all, I'm wanting to play with D and openGL on a Mac.  I've managed to 
> compile vanilla GCC sources with the GDC patch, and can happily compile 
> the example app.
> However, I can't figure out how to link against opengl libraries. 
> Apple's version of GCC has a -framework option, which GDC and vanilla 
> GCC don't recognise.

The linker *does* recognize it, so you can use -Wl,-framework,-OpenGL

I have done a patch to add -framework support and some other
Mac stuff to the GDC build, but it has not been released yet...
(and it probably won't be for another weeks/months, either)

> My next step was to try to compile Apple's GCC tree with the D patches, 

As you found out, this does not work...
Apple's GCC tree has *tons* of patches.

> Also, I tried to enable --altivec on the vanilla GCC build and the build 
> failed due to some "forcecpusubtype_ALL" option missing - am I missing 
> something here?

Yeah, that AltiVec doesn't work either? :-P

You can write a function in C (*not* using Altivec registers outwards),
compile it with Apple's compiler and then link it with the D programs.
The same song-and-dance routine is required for using PPC assembler...

--anders
March 20, 2005
Re: OS X, gdc and opengl
> The linker *does* recognize it, so you can use -Wl,-framework,-OpenGL

Make that -Wl,-framework,OpenGL ... (silly typo snuck in)

As in:
LDFLAGS=-Wl,-framework,OpenGL -Wl,-framework,GLUT -lobjc

--anders
March 20, 2005
Re: OS X, gdc and opengl
Anders F Björklund wrote:

> Brad Beveridge wrote:
> 
>> Hi all, I'm wanting to play with D and openGL on a Mac.  I've managed 
>> to compile vanilla GCC sources with the GDC patch, and can happily 
>> compile the example app.
>> However, I can't figure out how to link against opengl libraries. 
>> Apple's version of GCC has a -framework option, which GDC and vanilla 
>> GCC don't recognise.
> 
> 
> The linker *does* recognize it, so you can use -Wl,-framework,-OpenGL
Thanks for that Anders.  I am recompiling gdc now - why did I delete it! :)
I don't quite understand what you are saying with the linker recognising 
-framework, could you please post a trivial example of how to compile & 
link a D file that needs OpenGL?  I tried

opengltestd: opengltest.d
gdc $< -I../SDL -L/sw/lib -lSDLmain -lSDL -framework OpenGL -lpthread 
-lGL -lglut -lGLU -o $@

And had no luck - google also didn't turn up any hints for me.

Thanks
Brad
March 20, 2005
Re: OS X, gdc and opengl
I'll reply to my own message - Thanks for the typo correction, I think I 
get it now :)  Just looked very odd with -Wl,-framework,-OpenGL

Brad
March 20, 2005
Re: OS X, gdc and opengl
Brad Beveridge wrote:

> Apple's version of GCC has a -framework option, which GDC and vanilla 
> GCC don't recognise.

While the polished version has not been released, the raw patches have:
http://dstress.kuehne.cn/raw_results/mac-OS-X-10.3.7_gdc-0.10-patch/
gcc-3.3.5-framework-headers.patch
gcc-3.3.5-framework-linker.patch
gdc-0.8-framework.patch

taken from the original Apple source code for Xcode version 1.1, at:
http://www.opensource.apple.com/darwinsource/DevToolsDec2003/gcc-1495/
(haven't checked if they updated the patches in Xcode 1.2 or 1.5, but)

--anders
March 20, 2005
Re: OS X, gdc and opengl
Brad Beveridge wrote:

> I don't quite understand what you are saying with the linker recognising 
> -framework, could you please post a trivial example of how to compile & 
> link a D file that needs OpenGL?  I tried

"-framework" goes to the compiler, which will choke on the unrecognized
option. By using "-Wl", you can pass whatever you want to the linker...

> opengltestd: opengltest.d
> gdc $< -I../SDL -L/sw/lib -lSDLmain -lSDL -framework OpenGL -lpthread 
> -lGL -lglut -lGLU -o $@

You did not say that you wanted to use SDL, which is lots more fun since
it is written in Objective-C and requires a patched SDLmain library...

But anyway, the libraries are:
LDFLAGS_GL=-Wl,-framework,OpenGL -Wl,-framework,GLUT -lobjc
LDFLAGS_SDL=-Wl,-framework,SDL -Wl,-framework,Cocoa -Lsdl -lSDLmain_d

On Linux, they would instead be:
LDFLAGS_GL=-lGL -lGLUT
LDFLAGS_SDL=-lSDL

I should have an updated example up sometime next week.
The old example does not compile at the moment, but when
it did it was running both GL "gears" and SDL "testbitmap".

--anders
March 20, 2005
Re: OS X, gdc and opengl (Fink)
Brad Beveridge wrote:

> gdc $< -I../SDL -L/sw/lib -lSDLmain -lSDL -framework OpenGL -lpthread 
> -lGL -lglut -lGLU -o $@

"/sw/lib":
By the way, I wouldn't recommended mixing GDC and Fink at the moment!

In my own setup, I have Apple's original stuff living under /usr,
Fink under /sw, GDC under /opt/gdc and my own hacks in /usr/local...

The current GDC does not really fit into the /usr or /sw hierarchies,
since it might cause conflicts with the default GCC compilers used ?

And it also makes it easier to uninstall, without a package manager.

--anders
March 20, 2005
Re: OS X, gdc and opengl (Fink)
Anders F Björklund wrote:

> Brad Beveridge wrote:
> 
>> gdc $< -I../SDL -L/sw/lib -lSDLmain -lSDL -framework OpenGL -lpthread 
>> -lGL -lglut -lGLU -o $@
> 
> 
> "/sw/lib":
> By the way, I wouldn't recommended mixing GDC and Fink at the moment!
> 
> In my own setup, I have Apple's original stuff living under /usr,
> Fink under /sw, GDC under /opt/gdc and my own hacks in /usr/local...
> 
> The current GDC does not really fit into the /usr or /sw hierarchies,
> since it might cause conflicts with the default GCC compilers used ?
> 
> And it also makes it easier to uninstall, without a package manager.
> 
> --anders
Thanks for all the great tips and help Anders.  As you might have 
guessed, I am new (about 5 days) to the OSX world.  I'm expecting to 
make quite a few bloopers yet :)

Brad
March 21, 2005
Re: OS X, gdc and opengl (Fink)
Anders F Björklund wrote:
> Brad Beveridge wrote:
> 
>> gdc $< -I../SDL -L/sw/lib -lSDLmain -lSDL -framework OpenGL -lpthread 
>> -lGL -lglut -lGLU -o $@
> 
> 
> "/sw/lib":
> By the way, I wouldn't recommended mixing GDC and Fink at the moment!
> 
> In my own setup, I have Apple's original stuff living under /usr,
> Fink under /sw, GDC under /opt/gdc and my own hacks in /usr/local...
> 
> The current GDC does not really fit into the /usr or /sw hierarchies,
> since it might cause conflicts with the default GCC compilers used ?
> 
> And it also makes it easier to uninstall, without a package manager.
> 
> --anders
What is the default version for GDC on OS X (ie, linux, Win32, etc) - 
and how should I find out (apart from asking here :)

Brad
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home