Thread: [Plib-users] Building Plib on Mac OSX (Darwin)
Brought to you by:
sjbaker
From: Reed H. <re...@ze...> - 2001-12-28 15:06:26
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm trying to build Plib on Mac OSX (Darwin). Has anyone else done this? I am trying to use the standard Apple "OpenGL" framework, but it is missing glx.h, which seems to be required. I have also had to do some minor modification to Makefile and source. If anyone has any info on Plib for Mac OSX, that woudl be great. Thanks reed - -- Reed Hedges re...@ze... http://zerohour.net/~reed Virtual Object System -- Internet Virtual Reality: http://www.interreality.org The owls are not what they seem. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (Darwin) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjwsim0ACgkQ43zrjhPEi79kfQCeIq4ZGYk87SVJvqJWBt9zMnre EiAAoJ7rQ1BAYGaVoggrYRO6tj0zQaQn =1RUW -----END PGP SIGNATURE----- |
From: Sebastian U. <ud...@ha...> - 2001-12-28 16:51:31
|
On Fri, 28 Dec 2001, re...@ze... (Reed Hedges) wrote: > Date: Fri, 28 Dec 2001 10:06:16 -0500 > To: pli...@li... > From: re...@ze... (Reed Hedges) > Subject: [Plib-users] Building Plib on Mac OSX (Darwin) > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > > Hi, I'm trying to build Plib on Mac OSX (Darwin). Has anyone else done > this? I am trying to use the standard Apple "OpenGL" framework, but it > is missing glx.h, which seems to be required. I have also had to do some > minor modification to Makefile and source. > If anyone has any info on Plib for Mac OSX, that woudl be great. Hmm ... well, we need glx.h on Unix / X11-Systems in order to determine whether there is a valid OpenGL rendering context. These are the appropiate lines which can be found in pu/pu.cxx, ssg/ssg.cxx and fnt/fntTXF.cxx: #ifndef WIN32 # ifndef macintosh # include <GL/glx.h> # else # include <agl.h> # endif #endif /* [...] */ static bool glIsValidContext () { #if defined(CONSOLE) return true ; #elif defined(WIN32) return ( wglGetCurrentContext () != NULL ) ; #elif defined(macintosh) return ( aglGetCurrentContext() != NULL ) ; #else return ( glXGetCurrentContext() != NULL ) ; #endif } I guess this has to be modified for Mac OS X ? - Sebastian |
From: Steve B. <sjb...@ai...> - 2001-12-28 17:03:58
|
Sebastian Ude wrote: > Hmm ... well, we need glx.h on Unix / X11-Systems in order to determine > whether there is a valid OpenGL rendering context. Yes - although PLIB still works without that check. As a desperation measure, you could comment out the entire contents of glIsValidContext() and have it just return TRUE for OSX...the only reason I dislike that as a solution is that this is a check for an annoyingly common application error that *seems* like it's a PLIB error. Without that check, we get lots of hard-to-diagnose errors reported to this mailing list that are not really our fault. Does OSX still use the 'agl' calls like earlier Mac's - or is it truly using X-windows and hence *must* support glX calls (and therefore should have glx.h) ? ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |
From: Reed H. <re...@ze...> - 2001-12-28 20:16:39
|
Hi, thanks for the help. Since sending that message I found AGL and used that, and Plib builds. Here is what I did to get ssg building, and similiar modifications to sg and util: 1. added "-framework OpenGL -framework AGL -framework CoreServices" to LIBS in the Makefile 2. changed some #include statements accordingly: from <GL/foo.h> to <OpenGL/foo.h> from <ag.h> to <AGL/agl.h> from <CodeFragments.h> in util/ul.h to <CoreServices/CoreServices.h>. I also added #include <unistd.h> to util/ul.h after CoreServices (for the sleep() function) 2. remove "-O6" from CXXFLAGS and CFLAGS in the Makefile ??? where did this come from ??? 3. add -Dmacintosh to DEFS in the Makefile. 4. changed int vp [ 4 ] ; on line 202 of ssg.cxx to GLint vp [ 4 ] ; 5. changed int ww; on line 112 of ssgLoadTexture.cxx to GLint ww; Frameworks are Darwin's way of doing libraries, they are versioned bundles (directories, actually) of headers, libraries and resources... to link to a framework SOMEFW, you pass '-framework SOMEFW' to cc, and to include header files out of it you include <SOMEFW/header.h>. Frameworks are a nice idea... but a pain in the ass for porting stuff from other unix platforms... I'm working on the Tux example program now. Here is the error, which has me stumped. I will try to enlist the help of some people who know more about OSX than me... linked to -framework GLUT and include <GLUT/glut.h> instead of <GL/glut.h>. make: c++ -g -O2 -Wall -o tux_example tux_example.o -lplibssg -lplibsg -lplibul -lpthread -lm -framework OpenGL -framework AGL -framework CoreServices -framework GLUT /usr/bin/ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib make: *** [tux_example] Error 1 -- Reed Hedges re...@ze... http://zerohour.net/~reed Virtual Object System -- Internet Virtual Reality: http://www.interreality.org The owls are not what they seem. |
From: Sebastian U. <ud...@ha...> - 2001-12-28 20:46:00
|
On Fri, 28 Dec 2001, re...@ze... (Reed Hedges) wrote: > Date: Fri, 28 Dec 2001 15:16:12 -0500 > To: pli...@li... > From: re...@ze... (Reed Hedges) > Subject: Re: [Plib-users] Building Plib on Mac OSX (Darwin) [...] > 2. remove "-O6" from CXXFLAGS and CFLAGS in the Makefile ??? where did > this come from ??? The "-O6" stuff was removed recently in CVS. > 2. changed some #include statements accordingly: > from <GL/foo.h> to <OpenGL/foo.h> > from <ag.h> to <AGL/agl.h> > from <CodeFragments.h> in util/ul.h to > <CoreServices/CoreServices.h>. I also added #include <unistd.h> to > util/ul.h after CoreServices (for the sleep() function) I think we should add some more #ifdefs to the code so that PLIB automatically includes the correct header files on Mac OS X. > 3. add -Dmacintosh to DEFS in the Makefile. Hmm ... you had to do this manually ? We have to find a way to determine whether the machine we are compiling on is running Mac OS (X) *without* forcing the user to tell us ... > 4. changed int vp [ 4 ] ; on line 202 of ssg.cxx to GLint vp [ 4 ] ; > 5. changed int ww; on line 112 of ssgLoadTexture.cxx to GLint ww; Why exactly was this neccessary ? PLIB passes normal int / float (whatever) variables or pointers to these types to the OpenGL routines expecting a GL* data type all the time (just look at PUI), and up to now, this has not caused any trouble as far as I can tell. If it does on Mac OS X, we have to change lots of lines (okay, in this case, 'sed' would be our friend ...). > Frameworks are Darwin's way of doing libraries, they are versioned > bundles (directories, actually) of headers,libraries and resources... > to link to a framework SOMEFW, you pass '-framework SOMEFW' to cc, and > to include header files out of it you include <SOMEFW/header.h>. > Frameworks are a nice idea... but a pain in the ass for porting stuff > from other unix platforms... Hmm ... who knows how to properly implement that stuff in our (up to now, pretty simple) autoconf-based build system ? - Sebastian |
From: Steve B. <sjb...@ai...> - 2001-12-28 21:47:05
|
Sebastian Ude wrote: > > 2. remove "-O6" from CXXFLAGS and CFLAGS in the Makefile ??? where did > > this come from ??? > > The "-O6" stuff was removed recently in CVS. Dunno - some attempt to get more speed by increasing the optimisation level I guess. Does that cause problems to someone? > > 2. changed some #include statements accordingly: > > from <GL/foo.h> to <OpenGL/foo.h> > > from <ag.h> to <AGL/agl.h> > > from <CodeFragments.h> in util/ul.h to > > <CoreServices/CoreServices.h>. I also added #include <unistd.h> to > > util/ul.h after CoreServices (for the sleep() function) > > I think we should add some more #ifdefs to the code so that PLIB > automatically includes the correct header files on Mac OS X. Yes - definitely. Now that Mac==UNIX, we need to make better efforts to support the beast. > > 3. add -Dmacintosh to DEFS in the Makefile. > > Hmm ... you had to do this manually ? > > We have to find a way to determine whether the machine we are compiling on > is running Mac OS (X) *without* forcing the user to tell us ... Yes. Looking to see if glut.h is in <GLUT/glut.h> might be one way. I can't imagine any other company making it so difficult to write portable code! (OK - actually, can *easily* imagine one other). > > 4. changed int vp [ 4 ] ; on line 202 of ssg.cxx to GLint vp [ 4 ] ; > > 5. changed int ww; on line 112 of ssgLoadTexture.cxx to GLint ww; > > Why exactly was this neccessary ? Perhaps they somehow made the GL types *not* be a simple typedef or #define of the basic types. If that's true then writing good code is going to be VERY painful. > PLIB passes normal int / float (whatever) variables or pointers to these > types to the OpenGL routines expecting a GL* data type all the time (just > look at PUI), and up to now, this has not caused any trouble as far as I > can tell. Indeed. > If it does on Mac OS X, we have to change lots of lines (okay, in this > case, 'sed' would be our friend ...). Not really - in many cases the SSG API says that some parameter is an 'int' or a 'float' when really it's going to be passed into OpenGL. I doubt that it can be true in all cases - for example, just below where that 'int vp [ 4 ]' line is, we have: glMultMatrixf ( (float *) mat ) ; ^^^^^^ Notice that this *isn't* a GLfloat as MultMatrix specifies. > > Frameworks are Darwin's way of doing libraries, they are versioned > > bundles (directories, actually) of headers,libraries and resources... > > to link to a framework SOMEFW, you pass '-framework SOMEFW' to cc, and > > to include header files out of it you include <SOMEFW/header.h>. > > Frameworks are a nice idea... but a pain in the ass for porting stuff > > from other unix platforms... Yes - but surely the old way must work too? Apple clearly don't seem overly concerned about portability. Why else would they have moved glut.h ? > Hmm ... who knows how to properly implement that stuff in our (up to now, > pretty simple) autoconf-based build system ? I doubt you could use autoconf. It has things like '-L' and '-I' directives hardwired in. Perhaps we have to give up and treat it like we do MSVC and Borland under Windoze where we just distribute a complete parallel build environment. That will only work if there are reasonable numbers of Mac OSX users on the mailing list to keep them up to date though. ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |
From: Reed H. <re...@ze...> - 2001-12-29 16:33:23
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > The "-O6" stuff was removed recently in CVS. > Dunno - some attempt to get more speed by increasing the optimisation level > I guess. Yeah, except gcc 2.95.2 only goes up to -O3, according to the documentation I have... and it fails with -O6 :) > We have to find a way to determine whether the machine we are compiling on > is running Mac OS (X) *without* forcing the user to tell us ... autoconf will detect this. I think AC_CANONICAL_SYSTEM will set a variety of variables, including "build_alias" "host_alias", etc?? On darwin this will have the value "powerpc-apple-darwin5.2" uname will also output "Darwin". Also, the compiler probably defines some symbol (__DARWIN__ or something) that can be detected in preprocessing. I will find that out. >Yes. Looking to see if glut.h is in <GLUT/glut.h> might be one way. >> 4. changed int vp [ 4 ] ; on line 202 of ssg.cxx to GLint vp [ 4 ] ; >> 5. changed int ww; on line 112 of ssgLoadTexture.cxx to GLint ww; > Why exactly was this neccessary ? > Perhaps they somehow made the GL types *not* be a simple typedef or #define > of the basic types. If that's true then writing good code is going to be > VERY painful. yup... this OpenGL demands GLint... will this break existing applications on Darwin? If so, c'est la vie, I guess. It was only those two lines in ssg though, none in sg or util. I haven't tried building the other libraries yet. Is this a big problem do you think? > Yes - but surely the old way must work too? Only with some sneaky hacks. All the directories are different, nothing like normal unix system. Normal systems have /usr/lib/libfoo.so or /usr/lib/group/libfoo.so (in which case you use - - - -L /usr/lib/group) , and /usr/include/foo.h or /usr/include/group/foo.h (in which case you use #include <group/foo.h>). Darwin has /System/Library/Frameworks/group.framework/Headers/foo.h and /System/Library/Frameworks/group.framework/Libraries/libfoo.dylib. Actually, I first tried symlinks from /usr/local/lib/GL -> /System/Library/Frameworks/OpenGL.framework/Libraries and likewise for headers, but ran into all kinds of little problems. It was easier just to link to the framework. Fink <http://fink.sf.net> includes open GL libraries (Mesa?) with the XFree port, I *think*, but I diddn't want to get tangled with those just yet. However, maybe that would work better. I can look at that too. > Apple clearly don't seem overly concerned about portability. Why else would > they have moved glut.h ? All the framework stuff is inherited from NeXt, I think. Politics probably :P. Frameworks *do* facilitate distribution of libraries without install scripts that move copy files around (they can just be dropped into place), which is nice. > Hmm ... who knows how to properly implement that stuff in our (up to now, > pretty simple) autoconf-based build system ? > I doubt you could use autoconf. It has things like '-L' and '-I' directives > hardwired in. Maybe just do what I did, but in the script-- detect darwin and append the framework directives, checking for OpenGL first, maybe, but it should be in any stock system AFAIK. I'm not sure how to implement this in autoconf though. There might be a way to get autoconf on Darwin to add in the frameworks automatically, though. I'll look for docs on it. > Perhaps we have to give up and treat it like we do MSVC and Borland under > Windoze where we just distribute a complete parallel build environment. This is another solution, It's a bit of grunt work setting up the Apple Project Builder files, but it's not to bad. The plib components can be made into frameworks, and contianed in this other concept darwin has of "umbrella" frameworks... I might be able to do this, if there is interest. Want me to send a patch for autoconf and code if I get it all more or less working correctly? My motive is working on my apple laptop, rather than my linux server/ desktop... which doesnt have a monitor :) But I can't spend too much time on it, I want to *use* plib :D I can get a monitor... Also: 1. is there a really minimal sample program I can use to test? 2. I ran configure script with --without-x. How important is X windows to any part of using plib? thanks reed -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (Darwin) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjwt528ACgkQ43zrjhPEi7/oUQCg6aYG3SPNoqzwSKpm4ouGcT+A jmYAoJrUhfw81UDAs1eB+ut2yc2AvEkV =wQ0O -----END PGP SIGNATURE----- |
From: Steve B. <sjb...@ai...> - 2001-12-29 17:45:36
|
Reed Hedges wrote: > > The "-O6" stuff was removed recently in CVS. > > > Dunno - some attempt to get more speed by increasing the optimisation > level > > I guess. > > Yeah, except gcc 2.95.2 only goes up to -O3, according to the > documentation I have... > and it fails with -O6 :) No it doesn't... /u/steve> gcc -O2 t1.cxx /u/steve> gcc -O6 t1.cxx /u/steve> gcc -O9 t1.cxx /u/steve> gcc --version 2.95.2 Doesn't seem to be a problem. I don't think you'll get any better optimisation after -O3 though. > yup... this OpenGL demands GLint... will this break existing > applications on Darwin? Almost no OpenGL programs would compile 'out of the box' if all GL types were rigerously enforced. But since Darwin appears to only be checking that GLint != int...you may 'get away with it' with many programs. > If so, c'est la vie, I guess. It was only those two lines in ssg > though, none in sg or util. I find that *very* suprising. Evidently it doesn't object to you passing a float in place of a GLfloat and I guess there are relatively few places where we pass integers into OpenGL. > Only with some sneaky hacks. All the directories are different, nothing > like normal unix system. Ack! What a pain. > Also: > 1. is there a really minimal sample program I can use to test? Most of the programs in the PLIB examples are pretty minimal. You have to download those separately from the PLIB web site. > 2. I ran configure script with --without-x. How important is X > windows to any part of > using plib? Not at all - PLIB runs under Windoze without X. ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |
From: Bernie B. <bb...@bi...> - 2001-12-29 23:32:25
|
Steve Baker wrote: > > Reed Hedges wrote: > > > > The "-O6" stuff was removed recently in CVS. > > > > > Dunno - some attempt to get more speed by increasing the optimisation > > level > > > I guess. > > > > Yeah, except gcc 2.95.2 only goes up to -O3, according to the > > documentation I have... > > and it fails with -O6 :) > > No it doesn't... > > /u/steve> gcc -O2 t1.cxx > /u/steve> gcc -O6 t1.cxx > /u/steve> gcc -O9 t1.cxx > /u/steve> gcc --version > 2.95.2 > > Doesn't seem to be a problem. I don't think you'll get any better optimisation > after -O3 though. > According to the manual everyything above -O3 is undocumented so YMMV. Anyways embedding compiler specific options in the autoconf/automake files is considered bad form. The approved method is to set CXXFLAGS in the environment before running configure: CXX=/usr/intel/ia32/bin/icc CXXFLAGS="-tpp6 -unroll -Kc++eh" ./configure Cheers, Bernie |
From: Beegee <be...@ma...> - 2001-12-29 23:05:16
|
I resolved the __objcInit error by linking against libobjc, from /usr/lib. There was some discussion about this on the ProjectBuilder list, but I don't have the thread handy. Also, I've made basically the exact same changes that you listed except that I kept 'macintosh' and 'MACOSX' as separate targets because of things like <OpenGL/GL.h> vs <GL/GL.h>. Additionally, there was a bug in 10.1 I believe that caused a crash if you called aglGetCurrentContext() before you created a context. That led me to just have glIsValidContext() always return true on OS X. Sloppy I know... Jon On Friday, December 28, 2001, at 12:16 PM, Reed Hedges wrote: > I'm working on the Tux example program now. Here is the error, which > has me stumped. I will try to enlist the help > of some people who know more about OSX than me... > > linked to -framework GLUT and include <GLUT/glut.h> instead of > <GL/glut.h>. > > > make: > c++ -g -O2 -Wall -o tux_example tux_example.o -lplibssg -lplibsg > -lplibul -lpthread -lm -framework OpenGL -framework AGL -framework > CoreServices -framework GLUT > /usr/bin/ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit > defined in indirectly referenced dynamic library > /usr/lib/libobjc.A.dylib > make: *** [tux_example] Error 1 > |
From: Reed H. <re...@ze...> - 2001-12-30 19:48:06
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jon, have you been working on plib on OSX? How much have you got working? I have working for me everything except fnt, and sl and js (need some bigger porting) and haven't looked at net at all. Basically the tux ssg example, the simple and complex pui examples (but not widget_list). Segfault somewhere in puFilePicker::setSize(). Is any OSX stuff in CVS yet? I was going to put together a patch, but would like to know what's there already. Would it be possible for me to check out the CVS tree, to find a recent tarball somewhere? On Saturday, December 29, 2001, at 06:03 PM, Beegee wrote: > I resolved the __objcInit error by linking against libobjc, from > /usr/lib. There was some discussion about this on the ProjectBuilder > list, but I don't have the thread handy. yup, that works fine. I think some of the OpenGL library is in Objective-C ("cocoa") > > Additionally, there was a bug in 10.1 I believe that caused a crash if > you called aglGetCurrentContext() before you created a context. That > led me to just have glIsValidContext() always return true on OS X. > Sloppy I know... > Yeah, most of Carbon AGL is "Unsupported" according to the on-line docs, and aglGetCurrentContext() doesn't work, and needs to be removed. There are equivalents in the Objective-C ("Cocoa") OpenGL interfaces, that I will try out. > Also, I've made basically the exact same changes that you listed except that I kept 'macintosh' and 'MACOSX' as separate > targets because of things like <OpenGL/GL.h> vs <GL/GL.h>. What macros are defined on MacOSX? I know __APPLE__ and __MACH__ are, are there any that just mean "you're on MacOSX" ? ("__MACOSX__" or something?). I think stuff like: #if defined(__APPLE__) && defined(__MACH__) // Mac OSX #include <OpenGL/gl.h> #else #include <GL/gl.h> #endif would work pretty fine (or probably just #ifdef __MACH__). Do you guys agree? If so, I'll make up the patch. I'm still not sure how to get the correct linker flags into the Makefiles via autoconf (will look into it sometime) but this is what's needed in the Makefiles for OSX: There should be no X11 libraries at all ("-lX11 -lXi -lXext -lXmu"). This is not a problem in the libraries, because the X libraries aren't actually linked, but I had to remove those flags when building the example programs. These flags should be added in these makefiles: ssg/Makefile: LIBS += -framework OpenGL pui/Makefile: LIBS += -framework GLUT All of the examples I tried: LIBS += -lobjc -framework OpenGL - -framework GLUT Let me know about CVS, patching, and if anyone knows about making autoconf work. rh - -- Reed Hedges re...@ze... http://zerohour.net/~reed Virtual Object System -- Internet Virtual Reality: http://www.interreality.org The owls are not what they seem. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (Darwin) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjwvaNEACgkQ43zrjhPEi7/pTQCfRkrZXChfK2ZQjgN6Z7z/vUES pvsAoLnj+ocrP9jOyWSq5QDA01WufHO6 =0j7b -----END PGP SIGNATURE----- |
From: Norman V. <nh...@ca...> - 2001-12-30 01:54:09
|
Reed Hedges writes: >2. remove "-O6" from CXXFLAGS and CFLAGS in the Makefile ??? where did >this come from ??? To set history straight The -O6 has been in configure.in 'forever' . When PLib was first setup for gnu autotools we didn't have an autotools expert on board and I borrowed a lot from the PGCC project http://www.goof.com/pcg/ to include the recommended flags to get the 'most' from their compiler. I am glad to say we have all learned a lot since then, and the right way is of course is to not hardwire this into the configure script as is reflected in the current CVS. Note that this allows for configure invocations such as CXXFLAGS="-OMyWhatAmIDoing" ./configure YMMV :-) Cheers Norman |