Eric's Page

Fixes and Tips

After finding so many useful tips and bug-fixes on forums and blogs, I decided to finally start listing the things I have figured out so that all you other crazy programmers can save some time.  Below you'll find some things that took me a while to figure out.  Some of these tips may exist elsewhere online, but I thought they were worth reproducing here.

Compiling Portaudio on Mac OS X 10.5/6  

9-30-2009

I recently upgraded to Snow Leopard, so I had trouble compiling the Portaudio audio I/O library.  Make sure you have the Mac SDK in /Developer/SDKs/MacOSX10.5.   This comes with the version of XCode (3.1 I believe) that came with Leopard, which you should be able to download online as well.  I also have a /Developer/SDKs/MacOSX10.6 directory which came with the version of XCode (3.2) that comes with Snow Leopard.

Per the instruction for compiling on Mac OSX on the Portaudio website, run "./configure" from the portaudio directory.  Configure should complete successfully if you have installed XCode.  The next step is to run "make".  If you are running on a 64bit architecture, this will result in compilation errors similar to the following:

...
cc1: warnings being treated as errors
src/common/pa_dither.c: In function 'PaUtil_Generate16BitTriangularDither':
src/common/pa_dither.c:73: warning: right shift count >= width of type
src/common/pa_dither.c:74: warning: right shift count >= width of type
src/common/pa_dither.c: In function 'PaUtil_GenerateFloatTriangularDither':
src/common/pa_dither.c:100: warning: right shift count >= width of type
src/common/pa_dither.c:101: warning: right shift count >= width of type
lipo: can't figure out the architecture type of: /var/folders/Yb/YbisVQwbFFiUBYFUlwO1yU+++TI/-Tmp-//cc52JJ8X.out
make: *** [src/common/pa_dither.lo] Error 1
...


We are getting type size errors.  The configure script correctly identified sizeof(long int) to be 8 bytes on our system; however, the 32bit systems that the make file is also compiling for don't like this.  To fix this, we need to edit the Makefile in the portaudio directory:

1. If you want to compile for 64bit systems, remove the 32bit architectures, "-arch ppc" and "-arch i386" from the CFLAGS and the LDFLAGS lists.  I also removed "-arch ppc64" since I don't have any use for it right now.

2. If you want to compile for the 32bit architectures, remove "-arch ppc64" and "-arch x86_64" from CFLAGS/LDFLAGS.  Then change "-DSIZEOF_LONG=8" to "-DSIZEOF_LONG=4" under the list of CFLAGS.

Now just run "make clean" and then "make" and it should all compile.