Pergunta

Eu estou passando mundo real Haskell , e chegou ao exemplo:

-- file: ch04/InteractWith.hs
-- Save this in a source file, e.g. Interact.hs

import System.Environment (getArgs)

interactWith function inputFile outputFile = do
  input <- readFile inputFile
  writeFile outputFile (function input)

main = mainWith myFunction
  where mainWith function = do
          args <- getArgs
          case args of
            [input,output] -> interactWith function input output
            _ -> putStrLn "error: exactly two arguments needed"

        -- replace "id" with the name of our function below
        myFunction = id

Mas quando eu tento compilá-lo (ghc --make InteractWith) eu recebo este erro:

$ ghc --make InteractWith
[1 of 1] Compiling Main             ( InteractWith.hs, InteractWith.o )

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:309:0:
    suffix or operands invalid for `push'

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:358:0:
    suffix or operands invalid for `push'

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:384:0:
    32-bit absolute addressing is not supported for x86-64

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:384:0:
    cannot do signed 4 byte relocation

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:387:0:
    32-bit absolute addressing is not supported for x86-64

/var/folders/38/38dlZO7fEXyCgGIFUZA0Ok+++TI/-Tmp-/ghc91310_0/ghc91310_0.s:387:0:
    cannot do signed 4 byte relocation

Eu estou usando GHC 6.10.4 no Mac OS 10.6 (Snow Leopard).

Foi útil?

Solução

Eu estava tendo problemas semelhantes compilando quase tudo no Snow Leopard. A solução que eu encontrei foi a de substituir o conteúdo de /usr/bin/ghc (que na verdade é apenas um script shell) com o seguinte:

#!/bin/sh

exec /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc -B/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/. -optc-m32 -opta-m32 -optl-m32 -dynload wrapped ${1+"$@"}

Eu acho que é realmente apenas adicionando -optc-m32 -opta-m32 -optl-m32 mas eu não me lembro ...

(I originalmente encontrado isso em algum lugar nas internets, mas eu não me lembro onde. Ele me fez um exame tempo demasiado.)

Outras dicas

Você atualizar para o Snow Leopard recentemente? Eu acredito que isso acontece quando você está tentando usar um executável no Snow Leopard, que foi construído usando o Leopard.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top