1

OS X では、haskell の Cabal の zlib 前提条件をインストールしようとしています。次のエラーが表示されます。

$ sudo ./Setup build
Preprocessing library zlib-0.5.0.0…
ld: library not found for -lgmp
collect2: ld returned 1 exit status
linking dist/build/Codec/Compression/Zlib/Stream_hsc_make.o failed
command was: /usr/bin/gcc -lz -L/sw/lib/ghc-6.8.3/lib/bytestring-0.9.0.1.1 -L/sw/lib/ghc-6.8.3/lib/array-0.1.0.0 -L/sw/lib/ghc-6.8.3/lib/base-3.0.2.0 -L/sw/lib/ghc-6.8.3 -lm -lgmp -ldl dist/build/Codec/Compression/Zlib/Stream_hsc_make.o -o dist/build/Codec/Compression/Zlib/Stream_hsc_make

ライブラリ -lgmp は /sw/lib にあるので、手動で -L/sw/lib を追加すると、そのコマンド (「/usr/bin/gcc ...」) を正常に実行できます。問題は、sudo が /sw/lib を認識していないことです。見よ:

$ gcc -print-search-dirs | grep sw
libraries: =/lib/i686-apple-darwin9/4.0.1/:/lib/:/usr/lib/i686-apple-darwin9/4.0.1/:/usr/lib/:./i686-apple-darwin9/4.0.1/:./:/sw/lib/i686-apple-darwin9/4.0.1/:/sw/lib/:/usr/lib/gcc/i686-apple-darwin9/4.0.1/:/usr/lib/gcc/i686-apple-darwin9/4.0.1/:/usr/lib/gcc/i686-apple-darwin9/4.0.1/../../../../i686-apple-darwin9/lib/i686-apple-darwin9/4.0.1/:/usr/lib/gcc/i686-apple-darwin9/4.0.1/../../../../i686-apple-darwin9/lib/:/usr/lib/gcc/i686-apple-darwin9/4.0.1/../../../i686-apple-darwin9/4.0.1/:/usr/lib/gcc/i686-apple-darwin9/4.0.1/../../../
$ sudo gcc -print-search-dirs | grep sw
$ 

gcc の sudo バージョンに /sw/lib でライブラリを探すように指示するにはどうすればよいですか? root の .bash_profile に環境変数を追加する必要がありますか? もしそうなら、どれですか?

更新: おそらくこれを行うためのより適切な方法がありますが、これがうまくいきました。これを含むbashスクリプトを作成しました:

#!/bin/sh
export LIBRARY_PATH=/sw/lib:$LIBRARY_PATH
./Setup build

そして、私は走った

$ sudo ./script.sh

それは文句を言わずにzlibをコンパイルしました-万歳!残念ながら、cabal-install はまだエラーを出しています:

$ ./Setup configure
Configuring cabal-install-0.6.2…
Setup: At least the following dependencies are missing:
zlib >=0.4 && <0.6

だから私はcabal-installディレクトリに戻り(これは私が最初にやろうとしていることです)、実行しました...

$  ./bootstrap.sh

...そして、期待どおりにすべてをインストールしました。

4

3 に答える 3

1

なぜあなたはsudo今まで使うのですか?スーパーユーザーとしてコンパイルしないでください。通常のユーザーとしてコンパイルし、スーパーユーザーとしてインストールします。

于 2009-04-05T19:00:40.770 に答える
0

設定してみてくださいLDFLAGS=-L/sw/lib

于 2009-04-04T21:55:38.517 に答える
0

GHC には、OS X (Leopard、Tiger については不明) 用のインストーラが付属しています。唯一の問題は、macports や fink を使用している場合、GHC がインストールされていることをおそらく認識せず、独自のバージョンをインストールしようとすることです。

于 2009-04-05T16:20:45.227 に答える