Question

Je suis en train de parcourir le monde réel Haskell . exemple:

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

Mais lorsque j'essaie de le compiler ( ghc --make InteractWith ), le message d'erreur suivant s'affiche:

$ 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

J'utilise GHC 6.10.4 sur Mac OS 10.6 (Snow Leopard).

Était-ce utile?

La solution

J'avais des problèmes similaires lors de la compilation de presque tout dans Snow Leopard. La solution que j'ai trouvée consistait à remplacer le contenu de / usr / bin / ghc (qui n'est en réalité qu'un script shell) par ce qui suit:

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

Je pense que c'est en fait juste d'ajouter -optc-m32 -opta-m32 -optl-m32 mais je ne me souviens pas ...

(Au départ, j'ai trouvé cela quelque part sur les internets, mais je ne me souviens pas où. Cela m'a aussi pris un certain temps.)

Autres conseils

Avez-vous effectué une mise à jour vers Snow Leopard récemment? Je pense que cela se produit lorsque vous essayez d’utiliser un fichier exécutable dans Snow Leopard qui a été créé avec Leopard.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top