Pregunta

Estoy pasando por Haskell del mundo real , y llegué al ejemplo:

-- 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

Pero cuando intento compilarlo ( ghc --make InteractWith ) aparece este error:

$ 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

Estoy usando GHC 6.10.4 en Mac OS 10.6 (Snow Leopard).

¿Fue útil?

Solución

Estaba teniendo problemas similares al compilar casi cualquier cosa en Snow Leopard. La solución que encontré fue reemplazar el contenido de / usr / bin / ghc (que en realidad es solo un script de shell) con lo siguiente:

#!/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+"$@"}

Creo que en realidad solo está agregando -optc-m32 -opta-m32 -optl-m32 pero no puedo recordar ...

(Originalmente encontré esto en algún lugar de Internet, pero no recuerdo dónde. También me llevó un tiempo).

Otros consejos

¿Actualizaste a Snow Leopard recientemente? Creo que esto sucede cuando intentas usar un ejecutable en Snow Leopard que se creó con Leopard.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top