重複の可能性:
Haskell を静的ライブラリにコンパイルする方法は?
別のライブラリにリンクする GHC を使用してライブラリをコンパイルする際に問題がある人はいますか?
ファイル:
module TestLib where
foreign export ccall test_me :: IO (Int)
foreign import "mylib_do_test" doTest :: IO ( Int )
test_me = doTest
出力:
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.4
> ghc TestLib.hs -o test -no-hs-main -L../libmylib -lmylib
Linking test ...
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
>
「ar -r -s ...」を使用して「libmylib.a」ライブラリ ファイルを作成します。