www.digitalmars.com         C & C++   DMDScript  

D.gnu - OS X, gdc and opengl

reply Brad Beveridge <brad nowhere.org> writes:
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
Mar 20 2005
next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
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
Mar 20 2005
next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
 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
Mar 20 2005
prev sibling parent reply Brad Beveridge <brad nowhere.org> writes:
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
Mar 20 2005
next sibling parent Brad Beveridge <brad nowhere.org> writes:
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
Mar 20 2005
prev sibling next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
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
Mar 20 2005
next sibling parent reply Brad Beveridge <brad nowhere.org> writes:
Anders F Björklund wrote:

 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
Sorry for being so dense - I seem to be close, but not quite there yet Here is my compile command gdc opengltest.d -o opengltestd -I../SDL -L/sw/lib -Wl,-framework,OpenGL -Wl,-framework,GLUT -lobjc -lSDL -Wl,-framework,Cocoa -lSDLmain /usr/bin/ld: Undefined symbols: _SDL_main collect2: ld returned 1 exit status I couldn't use your command as I got this error gdc opengltest.d -o opengltestd -I../SDL -L/sw/lib -Wl,-framework,OpenGL -Wl,-framework,GLUT -lobjc -Wl,-framework,SDL -Wl,-framework,Cocoa -lSDLmain_d /usr/bin/ld: can't locate framework for: -framework SDL I've tried to get the OSX SDL framework installed, but to no avail. The SDL source fails in the ./configure stage (threading unsupported!), and the SDL OSX devel libraries specifically say the framework is not installed & to get it from the sources. Any help is much appreciated. Cheers Brad
Mar 20 2005
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Brad Beveridge wrote:

 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...
I've tried to get the OSX SDL framework installed, but to no avail. The SDL source fails in the ./configure stage (threading unsupported!), and the SDL OSX devel libraries specifically say the framework is not installed & to get it from the sources.
You need a special version of the SDLmain, that initializes the D runtime. It also needs to be called from your "main(char[][] args)"
 Any help is much appreciated.
SDL code will come later, just use plain GLUT in the meantime ? --anders
Mar 21 2005
parent Brad Beveridge <brad somewhere.net> writes:
<SNIP>
 SDL code will come later, just use plain GLUT in the meantime ?
 
 --anders
boohoo, sob! :) Yeah, maybe I'm jumping in just a tad deep. I'll back off and play with GLUT. I probably ought to become familiar with the Apple way of doing development also. All of my linux play apps are SDL based, so hopefully when I get a little smarter they'll all "Just Work" on OSX. Thanks for the help Anders Brad
Mar 21 2005
prev sibling parent reply Brad Beveridge <brad somewhere.net> writes:
 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
Hi again Anders - these examples that you mention, can you please tell me were to find them? Thanks Brad
Mar 22 2005
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Brad Beveridge wrote:

 Hi again Anders - these examples that you mention, can you please tell 
 me were to find them?
They're not updated and online just yet... They'll be on http://www.algonet.se/~afb/d/ --anders
Mar 22 2005
parent reply Brad Beveridge <brad somewhere.net> writes:
Anders F Björklund wrote:
 Brad Beveridge wrote:
 
 Hi again Anders - these examples that you mention, can you please tell 
 me were to find them?
They're not updated and online just yet... They'll be on http://www.algonet.se/~afb/d/ --anders
Fantastic, thanks!
Mar 22 2005
parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Brad Beveridge wrote:

 They're not updated and online just yet...
Fantastic, thanks!
Seems like the next GDC version will be a while, and so will a coherent download of SDL/GL for Mac. If you're anxious to get started, see my CVS rep. (or email me privately, it shouldn't be that hard) --anders
Mar 25 2005
next sibling parent Brad Beveridge <brad somewhere.net> writes:
Anders F Björklund wrote:
 Brad Beveridge wrote:
 
 They're not updated and online just yet...
Fantastic, thanks!
Seems like the next GDC version will be a while, and so will a coherent download of SDL/GL for Mac. If you're anxious to get started, see my CVS rep. (or email me privately, it shouldn't be that hard) --anders
Thanks Anders. I don't mind waiting :) I've got plenty to do to figure out how best to use OSX as a development environment. Brad
Mar 25 2005
prev sibling parent reply brad domain.invalid writes:
Anders F Björklund wrote:
 Brad Beveridge wrote:
 
 They're not updated and online just yet...
Fantastic, thanks!
Seems like the next GDC version will be a while, and so will a coherent download of SDL/GL for Mac. If you're anxious to get started, see my CVS rep. (or email me privately, it shouldn't be that hard) --anders
I played with your CVS tree last night, and managed to get the testgl program working fine. So I can start playing with my own SDL/D/MacOS stuff now :) Thanks for the good work. I take it the SDL stuff you've done is open source, or somesuch? Also, do you know if it is possible to profile GDC apps with Shark? I've heard a lot about Shark & I think I may play with that next. Brad
Mar 28 2005
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
brad domain.invalid wrote:

 Thanks for the good work.  I take it the SDL stuff you've done is open 
 source, or somesuch?
It's under the same license as the C headers, i.e. LGPL for SDL
 Also, do you know if it is possible to profile GDC apps with Shark? I've 
 heard a lot about Shark & I think I may play with that next.
Should be, just that the D name mangling is a little "strange"... --anders
Mar 28 2005
prev sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
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
Mar 20 2005
next sibling parent Brad Beveridge <brad nowhere.org> writes:
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
Mar 20 2005
prev sibling parent Brad Beveridge <brad nowhere.org> writes:
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
Mar 20 2005
prev sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
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
Mar 20 2005