Snow Leopard

This is a 64/32-bit confusion. It happens because the interrogate file was generated with the -D_LP64 flag, which means 64 bits. But then it is compiled with “-arch i386 -arch x86_64”, which means both 32 and 64 bits.

If you want a 32-bit Panda, you should remove “-arch x86_64” and replace -D_LP64 with -D__i386__. If you want a 64-bit Panda, you should remove “-arch i386” and leave -D_LP64.

At the moment, the build system isn’t smart enough to build a 32/64-bit universal binary in one pass.

David

Oh. I didn’t realize that when I added universal binary for Snow Leopard support to Makepanda. Sorry about that.

So, I think makepanda is detecting that you’re running on a 64-bits system. So you’d need to remove the “-arch i386” parameter, I think that should work.

It’s probably a good idea to remove the “built” directory after that. Makepanda is not smart enough to automatically force rebuilds when a compilation flag has changed.

Thanks David, rdb. That did the trick. Going for a 32bit version now.

Btw: another change (reported by Hypnos above), didn’t make it into cvs head: the change to panda/src/glstuff/glGraphicsStateGuardian_src.h (PFNGLTEXIMAGE3DPROC). The change is also necessary to get the compile beyond 46%.

Umn, it’s there, line 57. What exactly are you missing, or what is the compile issue?

Here is my diff. Sorry I don’t have the output from that build anymore.

RCS file: /cvsroot/panda3d/panda/src/glstuff/glGraphicsStateGuardian_src.h,v
retrieving revision 1.167
diff -r1.167 glGraphicsStateGuardian_src.h
57c57
< typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
---
> typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);

Hope that helps (I just did an cvs update to see if I was missing something).

Next problem:

rdb, do you have a more recent version of the thirdparty directory that can be downloaded from somewhere? I’m still using the one provided with 1.6.2. but that gives me

Couldn't find any of the libraries FColladaD, FColladaSD

and later down the road when linking:

[ 65%] Linking executable built/bin/dae2egg
g++ -o built/bin/dae2egg -Lbuilt/lib -Lbuilt/tmp -L/usr/X11R6/lib built/tmp/dae2egg_daeToEgg.o -ldaeegg -leggbase -lprogbase -lconverter -lpandatoolbase built/lib/libpandaegg.dylib built/lib/libpanda.dylib built/lib/libpandaexpress.dylib built/lib/libp3dtool.dylib built/lib/libp3dtoolconfig.dylib built/lib/libp3pystub.dylib -isysroot /Developer/SDKs/MacOSX10.5.sdk -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -Lthirdparty/darwin-libs-a/fcollada/lib -lFColladaD -framework AppKit -framework Carbon -lpthread -ldl
ld: library not found for -lFColladaD
collect2: ld returned 1 exit status

Thanks for the help.

Nevermind, I used --no-fcollada.

(Non-issue: even if --no-fcollada, there is still the warning saying “Couldn’t find any of the libraries FColladaD, FColladaSD”, but the compile/link is fine.)

Next issue i encountered was:

[ 83%] Building Flex object built/tmp/pvrml_vrmlLexer.o
flex    -Pvrmlyy -obuilt/tmp/vrmlLexer.lxx.cxx pandatool/src/vrml/vrmlLexer.lxx
g++ -ftemplate-depth-30 -fPIC -c -o built/tmp/pvrml_vrmlLexer.o -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -Ibuilt/tmp -Ibuilt/include -DMAKEPANDA= -Ipandatool/src/vrml -Wno-deprecated-declarations -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -O2 built/tmp/vrmlLexer.lxx.cxx
built/tmp/vrmlLexer.lxx.cxx: In function ‘int yy_get_next_buffer()’:
built/tmp/vrmlLexer.lxx.cxx:3991: error: invalid initialization of reference of type ‘int&’ from expression of type ‘yy_size_t’
pandatool/src/vrml/vrmlLexer.lxx:125: error: in passing argument 2 of ‘void input_chars(char*, int&, int)’

This is very similar to what David fixes in panda/src/egg/lexer.lxx. There is another occasion where this happens. This is my diff that made the compile continue:

Index: pandatool/src/vrml/vrmlLexer.lxx
===================================================================
RCS file: /cvsroot/panda3d/pandatool/src/vrml/vrmlLexer.lxx,v
retrieving revision 1.7
diff -r1.7 vrmlLexer.lxx
157c157,164
< #define YY_INPUT(buffer, result, max_size) input_chars(buffer, result, max_size)
---
> 
> // Define this macro carefully, since different flex versions call it
> // with a different type for result.
> #define YY_INPUT(buffer, result, max_size) { \
>   int int_result; \
>   input_chars((buffer), int_result, (max_size)); \
>   (result) = int_result; \
> }
Index: pandatool/src/xfile/xLexer.lxx
===================================================================
RCS file: /cvsroot/panda3d/pandatool/src/xfile/xLexer.lxx,v
retrieving revision 1.11
diff -r1.11 xLexer.lxx
150c150,157
< #define YY_INPUT(buffer, result, max_size) input_chars(buffer, result, max_size)
---
> 
> // Define this macro carefully, since different flex versions call it
> // with a different type for result.
> #define YY_INPUT(buffer, result, max_size) { \
>   int int_result; \
>   input_chars((buffer), int_result, (max_size)); \
>   (result) = int_result; \
> }

Er, I’m not so sure about applying that fix. My glext.h includes the version that we currently have. I think Apple is violating the OpenGL spec there.

Sure, here you go:
mac.rdb.name/~pro-rsoft/thirdparty-osx.tar.bz2

Don’t have any experience with flex myself, maybe David can take a look at your patch.

Yes, I believe you’re correct. On the other hand Panda3D won’t be able to compile without that “fix” of the OpenGL API on Snow Leopard. So maybe there needs to be a #ifdef block around this somehow? I don’t know how long it will take Apple to fix such an issue on their side.

Really? I’ve been compiling Panda on Snow Leopard for months, and I haven’t had a problem with this line.

Looking at the glext.h in my own /Developer/SDKs/MacOSX10.6.sdk/usr/X11/include/GL/glext.h, I see that its definition for PFNGLTEXIMAGE3DPROC matches ours. Is yours different somehow?

But even if it is, there are some #defines in glgsg.h that are supposed to prevent the system glext.h from even getting included in the first place, since system glext.h files are often broken in one way or another. So something else must be broken in your case. What is the precise compilation error you’re getting?

Edit: Oh, I see. Apple has indeed gone off-spec, and they’ve added these typedefs to /Developer/SDKs/MacOSX10.6.sdk/usr/X11/include/GL/gl.h for some reason (which is also the same thing as /usr/X11R6/include/GL/gl.h). But when I build Panda via ppremake, the OpenGL header file I’m building with is /System/Library/Frameworks/OpenGL.framework/Headers/gl.h, which correctly lacks these typedefs. Maybe makepanda points the build at the one in /usr/X11R6/include somehow? (I’m not sure how. We explicitly include OpenGL/gl.h in glgsg.h, so how can that possibly be picking up GL/gl.h accidentally?)

David

Hm. Could someone who is experiencing this problem try and put an “#error” statement somewhere in GL/gl.h, recompile, and report the output? cpp should show a tracepath when an error occurs.

I’ll see if I can get around to do try this on the weekend.

It took me some time to get it to work, but I can now build Panda3d on my shiny new Snow Leapord MacBook. After reading all the forums to get help, I felt that it would be ungrateful of me not to feed back what worked. I can’t guarantee that this method will work with everyone, but hopefully this will give you some clues so that the build works on your Mac.

I had to move my MacPorts folder out of the way to avoid confusion:
sudo mv /opt/local /opt/local_temporarily_dont_use

Before you start, you need to tell it to use 32 bit Python (or it gets unhappy)
export VERSIONER_PYTHON_PREFER_32_BIT=yes

Download the Mac source with ALL third party libraries: panda3d-1.7.0-mac.tar.gz.

In makepanda.py, force the architecture to be ONLY 32 bit.
I think this is because some of my MacPorts files were compiled to be 64 bit only, and not 32/64 bit hybrids.

In makepanda/makepanda.py, line 666 and 906

         cmd += " -arch i386 " 
   #     if int(platform.mac_ver()[0][3]) >= 6: 
   #     cmd += " -arch x86_64 -arch i386" 
   #     else: 
   #         cmd += " -arch i386" 
   #         if ("NOPPC" not in opts): cmd += " -arch ppc" 

We don’t want Mesa (especially on Mac), remove it by commenting the whole block out of makepanda.py, lines 3026 to 3038

In Line 749, set the -D_L bit at the end to be only 32 bit
cmd += ’ -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -D__const=const -D__i386__’

From the forums, I found that you need to patch these two files:
Index: pandatool/src/vrml/vrmlLexer.lxx

RCS file: /cvsroot/panda3d/pandatool/src/vrml/vrmlLexer.lxx,v
retrieving revision 1.7
diff -r1.7 vrmlLexer.lxx
157c157,164
< #define YY_INPUT(buffer, result, max_size) input_chars(buffer, result, max_size)

// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}
Index: pandatool/src/xfile/xLexer.lxx
===================================================================
RCS file: /cvsroot/panda3d/pandatool/src/xfile/xLexer.lxx,v
retrieving revision 1.11
diff -r1.11 xLexer.lxx
150c150,157
< #define YY_INPUT(buffer, result, max_size) input_chars(buffer, result, max_size)


// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

Now you can build everything:
makepanda/makepanda.py --everything
Go get your coffee while it compiles.

When you’re done and you wan to test it out, update your environment to point to your fresh new version

export VERSIONER_PYTHON_PREFER_32_BIT=yes
export DYLD_LIBRARY_PATH=/Users/chompy/chompygames/scratch/panda3d/built/lib
export PYTHONPATH=/Users/chompy/chompygames/scratch/panda3d/built:/Users/chompy/chompygames/scratch/panda3d/built/lib

Edit the file /Library/Python/2.6/site-packages/Panda3D.pth to point to:
/Users/chompy/chompygames/scratch/panda3d/built

If all goes well, you should be able to run your app now
python ChompyGames.py