Hello everyone, I have finally (actually about a week ago but I've been out of town) gotten FlightGear to compile under Mac OS X 10.2.4. The results were surprising and I am probably going to rub a few feathers the wrong way in the process of explanation. I don't mean to offend but I need to be clear about what I see happening and sometimes plain language offends people.
As you may recall, I was getting a linker error when linking fgfs. As someone more wise in the ways of ld than I pointed out, the method as compiled in tr.cxx was different from how the method call was being compiled in gui_funcs.cxx. The reason was that in tr.cxx, GLint was being defined as an integer, but in gui_funcs.cxx it was being defined as a long. Further exploration with the precompiler showed that SimGear was finding Apple's OpenGL gl.h, but FlightGear was finding XFree86's gl.h, and the two define GLint differently. Now I could just degenerate into name-calling about Apple's headers but as I looked around more in all the code that FlightGear uses I discovered that plib was not having any problems with the situation and that the linker wasn't complaining about the plib libraries. I found that plib's configure script was handling Mac OS X differently and specifically defining the location of glut.h to use Apple's OpenGL glut.h (which in turn includes gl.h). I am not a configure hacker but decided that I could emulate what plib was doing with some judicious complier defines in SimGear and FlightGear, just to see if it would work. I did and it did. It also took care of the error below that I had absolutely no idea how to address: ld: Undefined symbols: ssgVtxTable::ssgVtxTable[in-charge](unsigned, ssgVertexArray*, ssgNormalArray*, ssgTexCoordArray*, ssgColourArray*) Although, I still get this on my G4 tower where X, etc. are installed, even after I make the code changes in the attached patches. I was able to get FlightGear to compile from CVS by doing the following: - fresh install of Mac OS 10.2 (Jaguar) - install the 10.2.4 combined update - install the December 2002 Developer Tools - install the Apple update to GLUT, which just came out recently (just for kicks, probably isn't needed) - pull down CVS versions of plib, metakit, SimGear, and FlightGear - apply the attached patches - the patches to plib are per Jonathan Polley - the patches are against CVS from a few days ago - run the attached build scripts The compile does stop at one point, I haven't figured out why this is happening, but here is the event and the workaround (change gcc to g++): bash-2.05a$ cd SimGear/simgear/xgl/ bash-2.05a$ make clean test -z "libsgxgl.a" || rm -f libsgxgl.a rm -f *.o core *.core bash-2.05a$ make source='xgl.c' object='xgl.o' libtool=no \ depfile='.deps/xgl.Po' tmpdepfile='.deps/xgl.TPo' \ depmode=gcc /bin/sh ../../depcomp \ gcc -DHAVE_CONFIG_H -I. -I. -I../../simgear -I../.. -I/Users/david/Desktop/FlightGear-CVS/include -g -O1 -finline-limit=6 -finline-functions -faltivec -D_REENTRANT -c `test -f 'xgl.c' || echo './'`xgl.c xgl.c:10: header file 'GLUT/glut.h' not found cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode make: *** [xgl.o] Error 1 bash-2.05a$ source='xgl.c' object='xgl.o' libtool=no \ > depfile='.deps/xgl.Po' tmpdepfile='.deps/xgl.TPo' \ > depmode=gcc /bin/sh ../../depcomp \ > g++ -DHAVE_CONFIG_H -I. -I. -I../../simgear -I../.. > -I/Users/david/Desktop/FlightGear-CVS/include -g -O1 -finline-limit=6 > -finline-functions -faltivec -D_REENTRANT -c `test -f 'xgl.c' || echo './'`xgl.c bash-2.05a$ make source='xglUtils.c' object='xglUtils.o' libtool=no \ depfile='.deps/xglUtils.Po' tmpdepfile='.deps/xglUtils.TPo' \ depmode=gcc /bin/sh ../../depcomp \ gcc -DHAVE_CONFIG_H -I. -I. -I../../simgear -I../.. -I/Users/david/Desktop/FlightGear-CVS/include -g -O1 -finline-limit=6 -finline-functions -faltivec -D_REENTRANT -c `test -f 'xglUtils.c' || echo './'`xglUtils.c rm -f libsgxgl.a ar cru libsgxgl.a xgl.o xglUtils.o ranlib libsgxgl.a No X, Apple or XFree86, no OpenGL, no freeglut, or glut, or fink. Which may bother people. Some Mac OS X users may not want to bother with these, understandably, in which case the SimGear and FlightGear code will have to be changed to compile this way. Others, more inclined to compile everything from source, will not want these changes in the code (even though they are already in plib) or will insist on a configure-time switch determining one behavior or the other. But the code (i.e. configure scripts and #include statements) is going to have to be changed/updated/complicated to accommodate the fact that Mac OS X may not have X, may have Apple's X, or may have XFree86; that it may have Apple's OpenGL and GLUT or not, or any combination of the above, so long as these header discrepancies exist. One issue that I am dealing with is that the frame rate is poor, even though precompiled versions I have had in the past had good (~30 fps) rates. It could turn out that Apple's OpenGL and GLUT are the culprit, which would give momentum to requiring those libraries to be built or installed from fink. I don't know yet. Again, I apologize (and apologise) for a semi-rant. I want the information to be out there for the people who can do something with it, and more for the person starting out with FlightGear on Mac OS X, since I wrestled with this same problem for four or five months. Regards, David K. Drum [EMAIL PROTECTED]
Index: src/GUI/net_dlg.cxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/GUI/net_dlg.cxx,v retrieving revision 1.1.1.1 diff -u -u -r1.1.1.1 net_dlg.cxx --- src/GUI/net_dlg.cxx 10 Sep 2002 01:14:04 -0000 1.1.1.1 +++ src/GUI/net_dlg.cxx 28 Feb 2003 21:55:15 -0000 @@ -36,7 +36,11 @@ #include <simgear/misc/sg_path.hxx> #include <Include/general.hxx> +#ifndef __APPLE__ #include <GL/gl.h> +#else +#include <OpenGL/gl.h> +#endif #include <Main/globals.hxx> #include <Main/fg_props.hxx> Index: src/Model/panelnode.cxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Model/panelnode.cxx,v retrieving revision 1.4 diff -u -u -r1.4 panelnode.cxx --- src/Model/panelnode.cxx 17 Nov 2002 12:56:01 -0000 1.4 +++ src/Model/panelnode.cxx 28 Feb 2003 21:55:17 -0000 @@ -5,7 +5,11 @@ #include <simgear/compiler.h> #include <vector> +#ifndef __APPLE__ #include <GL/gl.h> +#else +#include <OpenGL/gl.h> +#endif #include <plib/sg.h> #include <Main/fg_props.hxx>
Index: src/js/js.h
===================================================================
RCS file: /cvsroot/plib/plib/src/js/js.h,v
retrieving revision 1.29
diff -u -r1.29 js.h
--- src/js/js.h 4 Jan 2003 02:55:53 -0000 1.29
+++ src/js/js.h 28 Feb 2003 21:51:04 -0000
@@ -95,9 +95,8 @@
#elif defined(UL_MAC_OSX)
IOHIDDeviceInterface ** hidDev;
- static const int kNumDevices;
static int numDevices;
- static io_object_t ioDevices[kNumDevices];
+ static io_object_t *ioDevices;
static void findDevices(mach_port_t);
static CFDictionaryRef getCFProperties(io_object_t);
Index: src/js/jsMacOSX.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/js/jsMacOSX.cxx,v
retrieving revision 1.1
diff -u -r1.1 jsMacOSX.cxx
--- src/js/jsMacOSX.cxx 4 Jan 2003 02:55:54 -0000 1.1
+++ src/js/jsMacOSX.cxx 28 Feb 2003 21:51:06 -0000
@@ -14,9 +14,9 @@
# include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
#endif
-int jsJoystick::kNumDevices = 32 ;
+
int jsJoystick::numDevices = -1;
-io_object_t jsJoystick::ioDevices[kNumDevices];
+io_object_t* jsJoystick::ioDevices = NULL;
jsJoystick::jsJoystick(int ident) :
id(ident),
@@ -44,6 +44,12 @@
// get the name now too
CFDictionaryRef properties = getCFProperties(ioDevices[id]);
+ if (!properties) {
+ ulSetError(UL_WARNING, "failed to get properties for JS device");
+ setError();
+ return;
+ }
+
CFTypeRef ref = CFDictionaryGetValue (properties, CFSTR(kIOHIDProductKey));
if (!ref)
ref = CFDictionaryGetValue (properties, CFSTR("USB Product Name"));
@@ -75,8 +81,14 @@
return;
}
+ // count them and allocate storage
+ while (IOIteratorNext(hidIterator)) ++numDevices;
+ ioDevices = new io_object_t[numDevices];
+ IOIteratorReset(hidIterator);
+
// iterate
io_object_t ioDev;
+ int index = 0;
while ((ioDev = IOIteratorNext(hidIterator))) {
// filter out keyboard and mouse devices
@@ -90,12 +102,14 @@
// exclude keyboard / mouse devices
if ((page == kHIDPage_GenericDesktop) &&
- ((usage == kHIDUsage_GD_Keyboard) || (usage ==
kHIDUsage_GD_Mouse))
- )
+ ((usage == kHIDUsage_GD_Keyboard) || (usage ==
kHIDUsage_GD_Mouse))) {
+ // we need to drop the numDevices count back down, since we
included
+ // these when allocating storage above.
+ --numDevices;
continue;
-
+ }
// add it to the array
- ioDevices[numDevices++] = ioDev;
+ ioDevices[index++] = ioDev;
}
IOObjectRelease(hidIterator);
Index: simgear/screen/tr.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/screen/tr.cxx,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 tr.cxx
--- simgear/screen/tr.cxx 7 Sep 2002 02:58:19 -0000 1.1.1.1
+++ simgear/screen/tr.cxx 28 Feb 2003 21:53:28 -0000
@@ -62,8 +62,13 @@
#ifdef WIN32
#include <windows.h>
#endif
+#ifndef __APPLE__
#include <GL/gl.h>
#include <GL/glu.h>
+#else
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#endif
#include <plib/ssg.h>
#include "tr.h"
Index: simgear/screen/tr.h
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/screen/tr.h,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 tr.h
--- simgear/screen/tr.h 7 Sep 2002 02:58:19 -0000 1.1.1.1
+++ simgear/screen/tr.h 28 Feb 2003 21:53:29 -0000
@@ -76,7 +76,11 @@
#define TR_H
+#ifndef __APPLE__
#include <GL/gl.h>
+#else
+#include <OpenGL/gl.h>
+#endif
//#ifdef __cplusplus
Index: simgear/sky/clouds3d/SkyContext.cpp
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/sky/clouds3d/SkyContext.cpp,v
retrieving revision 1.3
diff -u -u -r1.3 SkyContext.cpp
--- simgear/sky/clouds3d/SkyContext.cpp 10 Dec 2002 19:12:36 -0000 1.3
+++ simgear/sky/clouds3d/SkyContext.cpp 28 Feb 2003 21:53:31 -0000
@@ -30,7 +30,9 @@
#include GLUT_H
-#ifndef WIN32
+#if defined (__APPLE__)
+#include <OpenGL/CGLCurrent.h>
+#else if !defined (WIN32)
#include <GL/glx.h>
#endif
@@ -134,8 +136,10 @@
*/
SkyMaterial* SkyContext::GetCurrentMaterial()
{
-#ifdef WIN32
+#if defined (WIN32)
ContextMaterialIterator cmi = _currentMaterials.find(wglGetCurrentContext());
+#elif defined (__APPLE__)
+ ContextMaterialIterator cmi = _currentMaterials.find(CGLGetCurrentContext());
#else
ContextMaterialIterator cmi = _currentMaterials.find(glXGetCurrentContext());
#endif
@@ -162,8 +166,10 @@
*/
SkyTextureState* SkyContext::GetCurrentTextureState()
{
-#ifdef WIN32
+#if defined (WIN32)
ContextTextureStateIterator ctsi =
_currentTextureState.find(wglGetCurrentContext());
+#elif defined (__APPLE__)
+ ContextTextureStateIterator ctsi =
_currentTextureState.find(CGLGetCurrentContext());
#else
ContextTextureStateIterator ctsi =
_currentTextureState.find(glXGetCurrentContext());
#endif
@@ -190,15 +196,19 @@
SKYRESULT SkyContext::AddCurrentGLContext()
{
SkyMaterial *pCurrentMaterial = new SkyMaterial;
-#ifdef WIN32
+#if defined (WIN32)
_currentMaterials.insert(std::make_pair(wglGetCurrentContext(),
pCurrentMaterial));
+#elif defined (__APPLE__)
+ _currentMaterials.insert(std::make_pair(CGLGetCurrentContext(), pCurrentMaterial));
#else
_currentMaterials.insert(std::make_pair(glXGetCurrentContext(),
pCurrentMaterial));
#endif
SkyTextureState *pCurrentTS = new SkyTextureState;
-#ifdef WIN32
+#if defined (WIN32)
_currentTextureState.insert(std::make_pair(wglGetCurrentContext() , pCurrentTS));
+#elif defined (__APPLE__)
+ _currentTextureState.insert(std::make_pair(CGLGetCurrentContext() , pCurrentTS));
#else
_currentTextureState.insert(std::make_pair(glXGetCurrentContext() , pCurrentTS));
#endif
Index: simgear/sky/clouds3d/extgl.h
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/sky/clouds3d/extgl.h,v
retrieving revision 1.3
diff -u -u -r1.3 extgl.h
--- simgear/sky/clouds3d/extgl.h 17 Nov 2002 00:42:17 -0000 1.3
+++ simgear/sky/clouds3d/extgl.h 28 Feb 2003 21:53:53 -0000
@@ -30,7 +30,11 @@
#define __glext_h_
#define __GLEXT_H_
+#ifndef __APPLE__
#include <GL/gl.h>
+#else
+#include <OpenGL/gl.h>
+#endif
#ifndef APIENTRY
#define APIENTRY
Index: simgear/xgl/xgl.h
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/xgl/xgl.h,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 xgl.h
--- simgear/xgl/xgl.h 7 Sep 2002 02:58:19 -0000 1.1.1.1
+++ simgear/xgl/xgl.h 28 Feb 2003 21:53:58 -0000
@@ -10,8 +10,13 @@
# include <windows.h>
#endif
+#ifndef __APPLE__
#include <GL/gl.h>
#include <GL/glu.h>
+#else
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#endif
#include <stdio.h>
envars.sh
Description: Bourne shell script
plib.sh
Description: Bourne shell script
metakit.sh
Description: Bourne shell script
sg.sh
Description: Bourne shell script
fg.sh
Description: Bourne shell script
