Build failure for PortMidi on mac: incorrect Block.h

I'm trying to build PortMidi on the mac, and get the error shown below. It appears that an OSX header is trying to include a Block.h file and getting the GHC Block.h instead of the one it expects. I'm new to Haskell and even newer to cabal, so I'm not sure how to go about solving this. Incidentally, cabal, cabal-install, and the system PortMidi libraries are all up-to-date. %cabal install PortMidi Resolving dependencies... Configuring PortMidi-0.1.3... Preprocessing library PortMidi-0.1.3... Building PortMidi-0.1.3... [1 of 1] Compiling Sound.PortMidi ( Sound/PortMidi.hs, dist/build/Sound/PortMidi.o ) In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/FSEvents.h:28, from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:218, from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20, from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21, from portmidi/pm_mac/pmmacosxcm.c:38:0: /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:51:0: error: expected specifier-qualifier-list before ‘StgPtr’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:108:0: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘bdescr’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:163:0: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:174:0: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:187:0: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:198:0: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:219:0: error: expected ‘)’ before ‘n’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:223:0: error: expected ‘)’ before ‘n’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:235:0: error: expected declaration specifiers or ‘...’ before ‘nat’ /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include/Block.h:241:0: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘StgWord’ cabal: Error: some packages failed to install: PortMidi-0.1.3 failed during the building phase. The exception was: exit: ExitFailure 1 -- Brian

Hello Brian Possibly you need to supply extra-include-dirs (and extra-lib-dirs) to cabal. It looks like a C header can't be parsed - the Haskell FFI preprocessor will try to compile pmmacosxcm.c by calling out to a C compiler before GHC compiles the Haskell source. Unless the C header is wrong - unlikely in a established library like PortAudio, header files generally fail to parse only when they can't find other headers to include. I'm afraid I can't help on which particular extra-include-dirs you might need as I've never run PortAudio / PortMidi on OSX. On Windows I did find that I needed the latest PartAudio release, I couldn't get "previous stable" stable versions to compile with MinGW. Best wishes Stephen

Stephen Tetley wrote:
Possibly you need to supply extra-include-dirs (and extra-lib-dirs) to cabal.
I tried --extra-include-dirs=/usr/include (the directory where the real Block.h resides) and there was no change. Adding the -v flag showed cabal trying to build with this line: /usr/bin/ghc -Iportmidi/pm_common -Iportmidi/pm_mac -Iportmidi/porttime -I/usr/include -package base-3.0.3.1 -optc-msse2 -optc-O2 -odir dist/build -c portmidi/pm_mac/pmmacosxcm.c Since it still picked up the GHC Block.h instead of /usr/include/Block.h, it seems as though ghc searches its own headers before those specified with -I. I suspect if I had a way to change that, it would work. -- Brian
participants (2)
-
Brian Victor
-
Stephen Tetley