Re: Compiling standalone applications in Kics2

From: Michael Hanus <mh_at_informatik.uni-kiel.de>
Date: Mon, 03 Dec 2012 12:59:06 +0100

On 12/01/2012 03:06 AM, Larry D. Lee jr. wrote:
> I'm rying to compile a standalone program using Kics2, but the resulting
> program uses dynamic linking to load certain libraries. Ideally, I would
> like these libraries to be statically linked with the application so
> that I could install the binary on another system without having to
> install the missing libraries. Unfortunately, every method that I could
> think of to force static linking has failed. I've tried using :set to
> pass the following compiler flag to ghc ":set rts -optl-static". I've
> tried calling ghc directly on the .hs files generated by kics2 in
> ./.curry. And, so forth. Any help would be greatly appreciated.

It seems not so easy and I am not sure that my solution always works,
but at least it worked for the examples that I tried.

In order to tell ghc to link everything statically, it seems necessary
to pass the options "-static -optl-static -optl-pthread" to ghc.
Note that the KiCS2 option ":set rts -optl-static" that you tried
are only run-time options but not compilation options.

ghc compilation options can be set in KiCS2 by the command
":set ghc ...", i.e., for static linking you need to set

> :set ghc -static -optl-static -optl-pthread

in KiCS2. Then static linking should be performed when you create
an executable by the command ":save" (although the linker produces many
warnings). However, the setting of ghc options is only possible
in "local" installations of KiCS2. In "global" KiCS2 installations
(which are the default ones since they ensure faster compilation),
this option is disabled since all libraries are precompiled and there
might be conflicts when precompiled libraries are linked to programs
compiled with different ghc options. Thus, in order to set these
options, you have to install KiCS2 "locally". This can be easily done
by setting the variable

GLOBALINSTALL=no

in the main Makefile of KiCS2 before installing it. I hope this works.

Alternatively, we could also offer the setting of ghc options
in the standard global installation "at your own risk", if this is
desirable. Please let me know if this is a desired feature.

Best regards,

Michael
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mo Dez 03 2012 - 13:00:33 CET

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:12 CEST