Possible Duplicate:
How to compile Haskell to a static library?
Anyone have a problem compiling a library using GHC that links to another library?
File:
module TestLib where
foreign export ccall test_me :: IO (Int)
foreign import "mylib_do_test" doTest :: IO ( Int )
test_me = doTest
Output:
> 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
>
I make the "libmylib.a" library file using "ar -r -s ...".