how to link a minimal executable?

Krzysztof Skrzętnicki gtener at
Wed Aug 11 19:25:05 EDT 2010

As far as I know *it is* the minimal set of libraries. Each and every
package comes with another library. And if it depends on any other
library it will be included as well. Additionally there will be some
system libraries like the one which defines main entry point.

This will result in huge executables if you use many libraries. A way
around it is using dynamic libraries, which does decrease the size of
executable, but can increase the complexity of deployment.

Perhaps someone will know the details better than me.

Best regards,
Krzysztof Skrzętnicki

On Wed, Aug 11, 2010 at 23:31, Greg Fitzgerald <garious at> wrote:
> Is there any documentation or examples available that shows what needs to be
> linked to get a haskell executable to print "hello world"?  Instead of using
> GHC to link, I'm interested in using gcc, ar, or link directly.  For
> starters, what implements the entry point?
> $ cat Main.hs
> main = print "hello world"
> $ ghc -c Main.hs
> $ Vs8/VC/bin/link.exe -NOLOGO Main.o
> LINK : fatal error LNK1561: entry point must be defined
> I see using ghc -v, it links all sorts of stuff:
> $ ghc -v Main.hs
> ...
> *** Linker:
> ...
>  -lHSrtsmain -lHShaskell98- -lHSrandom- -lHStime-1.1.4
> -lHSprocess- -lHSdirectory- -lHSold-time-
> -lHSold-locale- -lHSfilepath- -lHSWin32- -luser32
> -lgdi32 -lwinmm -ladvapi32 -lshell32 -lshfolder -lHSbytestring-
> -lHSarray- -lHSbase- -lwsock32 -luser32
> -lshell32 -lHSinteger-simple- -lHSghc-prim- -lHSrts -lm
> -lwsock32 -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_GHCziConc_ensureIOManagerIsRunning_closure -u
> _base_GHCziConc_runSparks_closure -u _base_GHCziConc_runHandlers_closure
> -lHSffiReading
> Any insight would be greatly appreciated.
> Thanks,
> Greg
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list