在Mac Snow Leopard上编译Haskell“Hello World” - 未找到crt1.10.5.o

时间:2011-04-01 01:22:15

标签: macos haskell compilation

只是尝试编译一些简单的Haskell,但它没有找到c运行时,尽管事实上 他们就在那里

$ cat hello_world.hs
main = putStrLn "hello, world"

$ ghc --make hello_world
[1 of 1] Compiling Main             ( hello_world.hs, hello_world.o )
Linking hello_world ...
ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status

$ file /usr/lib/crt1.10.5.o 
/usr/lib/crt1.10.5.o: Mach-O universal binary with 3 architectures
/usr/lib/crt1.10.5.o (for architecture x86_64): Mach-O 64-bit object x86_64
/usr/lib/crt1.10.5.o (for architecture i386):   Mach-O object i386
/usr/lib/crt1.10.5.o (for architecture ppc7400):    Mach-O object ppc

$ uname -a
Darwin Nyx.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.2

我是从http://hackage.haskell.org/platform/mac.html

安装的

<小时/> 详细转储:

$ ghc -v --make hello_world
Glasgow Haskell Compiler, Version 7.0.2, for Haskell 98, stage 2 booted by GHC version 6.12.3
Using binary package database: /Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2/package.conf.d/package.cache
Using binary package database: /Users/Anm/.ghc/i386-darwin-7.0.2/package.conf.d/package.cache
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-6bf7b03ebc9c668817e4379b6796c0c2
wired-in package integer-gmp mapped to integer-gmp-0.2.0.3-91607778cf3ae8f3948a50062b4f8479
wired-in package base mapped to base-4.3.1.0-93953b308d1897309792406495cf356b
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.5.0.0-5134a59c0456de4c2a07cc56fa258728
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags: -static
*** Chasing dependencies:
Chasing modules from: *hello_world.hs
Stable obj: [Main]
Stable BCO: []
Ready for upsweep
  [NONREC
      ModSummary {
         ms_hs_date = Thu Mar 31 18:11:40 PDT 2011
         ms_mod = main:Main,
         ms_imps = [import Prelude]
         ms_srcimps = []
      }]
compile: input file hello_world.hs
Created temporary directory: /var/folders/UE/UEH-SvA7E-GPjyBwX5XrfU+++TI/-Tmp-/ghc13751_0
*** Checking old interface for main:Main:
[1 of 1] Skipping  Main             ( hello_world.hs, hello_world.o )
*** Deleting temp files:
Deleting: /var/folders/UE/UEH-SvA7E-GPjyBwX5XrfU+++TI/-Tmp-/ghc13751_0/ghc13751_0.s
Warning: deleting non-existent /var/folders/UE/UEH-SvA7E-GPjyBwX5XrfU+++TI/-Tmp-/ghc13751_0/ghc13751_0.s
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
link: linkables are ...
LinkableM (Thu Mar 31 18:11:51 PDT 2011) main:Main
   [DotO hello_world.o]
Linking hello_world ...
*** Linker:
/Developer/usr/bin/gcc -v -o hello_world -march=i686 -m32 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -fno-stack-protector -DDONT_WANT_WIN32_DLL_SUPPORT hello_world.o -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2/base-4.3.1.0 -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2/integer-gmp-0.2.0.3 -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2/ghc-prim-0.2.0.0 -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2 -lHSrtsmain -lHSbase-4.3.1.0 -liconv -lHSinteger-gmp-0.2.0.3 -lHSghc-prim-0.2.0.0 -lHSrts -lm -ldl -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOziException_stackOverflow_closure -u _base_GHCziIOziException_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOziException_blockedIndefinitelyOnMVar_closure -u _base_GHCziIOziException_blockedIndefinitelyOnSTM_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConcziIO_ensureIOManagerIsRunning_closure -u _base_GHCziConcziSync_runSparks_closure -u _base_GHCziConcziSignal_runHandlers_closure -Wl,-search_paths_first -read_only_relocs warning -lHSffi
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~123/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
 /Developer/usr/bin/../libexec/gcc/i686-apple-darwin10/4.2.1/collect2 -dynamic -arch i386 -macosx_version_min 10.5 -read_only_relocs warning -syslibroot /Developer/SDKs/MacOSX10.5.sdk -weak_reference_mismatches non-weak -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOziException_stackOverflow_closure -u _base_GHCziIOziException_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOziException_blockedIndefinitelyOnMVar_closure -u _base_GHCziIOziException_blockedIndefinitelyOnSTM_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConcziIO_ensureIOManagerIsRunning_closure -u _base_GHCziConcziSync_runSparks_closure -u _base_GHCziConcziSignal_runHandlers_closure -o hello_world -lcrt1.10.5.o -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2/base-4.3.1.0 -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2/integer-gmp-0.2.0.3 -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2/ghc-prim-0.2.0.0 -L/Library/Frameworks/GHC.framework/Versions/7.0.2-i386/usr/lib/ghc-7.0.2 -L/Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1 -L/Developer/usr/bin/../lib/gcc -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/Developer/usr/bin/../lib/gcc/i686-apple-darwin10/4.2.1/../../.. hello_world.o -lHSrtsmain -lHSbase-4.3.1.0 -liconv -lHSinteger-gmp-0.2.0.3 -lHSghc-prim-0.2.0.0 -lHSrts -lm -ldl -search_paths_first -lHSffi -lgcc_s.10.5 -lgcc -lSystem
ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status
*** Deleting temp files:
Deleting: 
*** Deleting temp dirs:
Deleting: /var/folders/UE/UEH-SvA7E-GPjyBwX5XrfU+++TI/-Tmp-/ghc13751_0

<小时/> 好的...... /usr/lib/gcc/i686-apple-darwin10/4.2.1/位于隐式库路径上,但是......

$ ls /usr/lib/gcc/i686-apple-darwin10/4.2.1/
crt3.o      include     libcc_kext.a    libgcc_eh.a libgcov.a   libgomp.spec    x86_64
finclude    install-tools   libgcc.a    libgcc_static.a libgomp.a   libstdc++.dylib

4 个答案:

答案 0 :(得分:2)

我有同样的问题。这是我的解决方案:

sudo ln -s /Developer/SDKs/MacOSX10.6.sdk /Developer/SDKs/MacOSX10.5.sdk

它只是有效!

答案 1 :(得分:1)

尝试使用-L选项明确告诉GHC搜索/usr/lib目录:

ghc -L/usr/lib --make hello_world

答案 2 :(得分:1)

GHC 7.0.3修复了Mac上的问题,获取该版本的最简单方法(等待下一个Haskell平台版本)是安装Homebrew版本的Haskell Package。

$ brew install haskell-platform
==> Downloading http://www.haskell.org/ghc/dist/7.0.3/ghc-7.0.3-i386-apple-darwin.tar.bz2

我不再需要这里描述的任何黑客。

答案 3 :(得分:0)

几个星期前在使用hakyll内置regex-pcre支持时遇到了类似的问题。 ghc -L / usr / lib对我来说在Snow Leopard上失败了(ghc仍然链接到/Developer/SDKs/MacOSX10.5.sdk/usr)。我真的不知道这是一个错误还是我无法完全理解ghc的奥秘。

无论如何,我解决它的方法是只将符号链接/ usr添加到/Developer/SDKs/MacOSX10.5.sdk/usr。丑陋,可怕的事情,但经过几个小时的ghc和输出库路径环境变量的斗争,我选择“工作”而不是“正确”。