Specify an arch in the GHC?

I am writing a multiplayer text adventure game ncurses. The required C library, ncursesw, is configured for x86, but my OS is Mac OS X 10.6.6 x86_64.

ghc --make -o rogue rogue.hs [1 of 2] Compiling Dungeon ( Dungeon.hs, Dungeon.o ) [2 of 2] Compiling Main ( rogue.hs, rogue.o ) Linking rogue ... ld: warning: in /usr/local/lib/libncursesw.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 

It is much easier for me to get compilation for x86 than to convince Homebrew, MinGW, and Aptitude repositories to include the ncursesw x86_64 library.

Is there a command line option that I can pass to ghc to specify an architecture similar to -march for GCC?

+6
x86 x86-64 haskell ncurses ghc
source share
2 answers

It looks like your ghc is configured for 32-bit ( i386 ), and the ncurses library is 64-bit ( x86-64 ). I believe that the latest Haskell Platform (2011.2.xx) uses 64-bit ghc, while earlier versions provided 32-bit ghc.

If you are using an earlier HP, the solution to this problem is probably enough to update this version.

Unfortunately, ghc is not a native cross-compiler, and you cannot set the architecture or size of a word using a flag. You will need a separate ghc for each architecture that you want to use, and you also need to make sure that all the libraries you refer to match this.

(BTW, x86 not enough to distinguish the architecture, since it can refer to 32-bit or 64-bit. This usually refers to the 32-bit version, but not always. At least on OSX 10.6 with Xcode 3, gcc rejects it as an invalid value for -march)

+2
source share

Use cabal and configure special flags for which the library should be included in the .cabal file.

eg.

 > if flag(use_altivec) > cc-options: > -DHAVE_ALTIVEC 

To force GHC to cross-compile (as you want it to), you need to install the x86 version of GHC (32 bit).

+1
source share

All Articles