Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gcc 带有数据集的Haskell程序未编译_Gcc_Haskell_Ghc - Fatal编程技术网

Gcc 带有数据集的Haskell程序未编译

Gcc 带有数据集的Haskell程序未编译,gcc,haskell,ghc,Gcc,Haskell,Ghc,我编写以下文件temp.hs: import qualified Data.Set import System.Environment main :: IO () main = do args <- getArgs let fname = head args print (fname) 当我试图编译它时,会出现以下错误: $ ghc temp.hs -o temp Undefined symbols: "___stginit_cont

我编写以下文件temp.hs:

import qualified Data.Set
import System.Environment

main :: IO ()
main = do
        args <- getArgs
        let fname = head args
        print (fname)
当我试图编译它时,会出现以下错误:

$ ghc temp.hs -o temp
Undefined symbols:
  "___stginit_containerszm0zi3zi0zi0_DataziSet_", referenced from:
      ___stginit_Main_ in temp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
如果我把导入的数据放出来,它编译的很好

版本信息:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.3

$ gcc --ver
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc_40/gcc_40-5494~112/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin10 --with-arch=apple --with-tune=generic --host=i686-apple-darwin10 --target=i686-apple-darwin10
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5494)
您可以在实际使用库时检查ghci可能需要的软件包:

  GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
  Loading package ghc-prim ... linking ... done.
  Loading package integer-gmp ... linking ... done.
  Loading package base ... linking ... done.
  Loading package ffi-1.0 ... linking ... done.
  Ok, modules loaded: Main.
  Prelude Main> Data.Set.singleton 0
> Loading package array-0.3.0.1 ... linking ... done.
> Loading package containers-0.3.0.0 ... linking ... done.
  fromList [0]
  Prelude Main> 

您可以单独添加包(正如KennyTM所建议的),也可以直接使用,这在许多方面都非常方便:

ghc --make temp.hs -o temp

这将导致GHC在其安装的软件包中以与GHCi完全相同的方式查找任何所需的模块。

此行为并非特定于Mac,因此最好删除
osx
Mac
标记和/或更改标题,因为这个问题可能对其他平台上的人有用。@travisbrown:谢谢!我删除了标签并更改了标题。
  GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
  Loading package ghc-prim ... linking ... done.
  Loading package integer-gmp ... linking ... done.
  Loading package base ... linking ... done.
  Loading package ffi-1.0 ... linking ... done.
  Ok, modules loaded: Main.
  Prelude Main> Data.Set.singleton 0
> Loading package array-0.3.0.1 ... linking ... done.
> Loading package containers-0.3.0.0 ... linking ... done.
  fromList [0]
  Prelude Main> 
ghc --make temp.hs -o temp