Hi Sergiy,<br><br><i>&gt;I thought having static library to solve my problem. And I&#39;m looking for how to build static library, but no luck.<br></i><br>I was also, originally trying to build a shared <i>static</i> library.<br>
(I wanted to distribute a plug-in, which could be used by people knowing nothing about Haskell working on machines that did not have the Haskell Platform installed.)<br><br>Then, I happened across this nugget in <a href="file:///usr/share/doc/ghc6-doc/html/users_guide/using-shared-libs.html#id2620284">section 4.11.3 of the GHC 6.12.3 User&#39;s Guide</a>:<br>
<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">In principle you can use <code class="literal">-shared</code> without
      <code class="literal">-dynamic</code> in the link step. That means to
      statically link the rts all the base libraries into your new shared
      library. This would make a very big, but standalone shared library.
      Indeed this is exactly what we must currently do on Windows where
      -dynamic is not yet supported (see <a class="xref" title="11.6. Building and using Win32 DLLs">Section 11.6, “Building and using Win32 DLLs
”</a>).
      On most platforms however that would require all the static libraries
      to have been built with <code class="literal">-fPIC</code> so that the code is
      suitable to include into a shared library and we do not do that at the
      moment.
    <br></blockquote><br>That is when I changed strategies and started trying to make a shared <i>dynamic</i> version of my library work.<br><br><b>A question to the group:<br><br></b>With regard to:<br><br>&quot;... that would require all the static libraries
      to have been built with <code class="literal">-fPIC</code> ...&quot;,<br><br>is this something I can do myself by re-cabaling with the proper options set in my <i>~/.cabal/config</i> file, or is this more involved than that?<br>
<br>Thanks,<br>-db<br><br>
    <div class="gmail_quote">On Sun, Sep 11, 2011 at 8:55 AM, Sergiy Nazarenko <span dir="ltr">&lt;<a href="mailto:nazarenko.sergiy@gmail.com">nazarenko.sergiy@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi, Captain,<br>
<br>
As far as I see you try to build static library.<br>
If this correct, what did not work in static library?<br>
Why do you decide compile with -dynamic option?<br>
<br>
I was trying to build shared library. Other python library has used<br>
some functions from library which I had written using Haskell. But<br>
some software which we use in my company had crached after attempts to<br>
import python module. Under pure python it works OK, but software has<br>
crached. I thought having static library to solve my problem. And I&#39;m<br>
looking for how to build static library, but no luck.<br>
<br>
Cheers,<br>
<font color="#888888">Sergiy<br>
</font><div><div></div><div class="h5"><br>
On 11 September 2011 17:56, Captain Freako &lt;<a href="mailto:capn.freako@gmail.com">capn.freako@gmail.com</a>&gt; wrote:<br>
&gt; Sergiy, Tom,<br>
&gt;<br>
&gt; Thanks for your replies.<br>
&gt;<br>
&gt; Sergiy, I was able to get this working without having to recompile my<br>
&gt; installed Haskell libraries.<br>
&gt;<br>
&gt; Tom, you were correct; I needed to explicitly link against the Haskell<br>
&gt; run-time system, as well as a few other things:<br>
&gt;<br>
&gt; I changed my ghc link options from this:<br>
&gt;<br>
&gt; HC_LOPTS = -no-hs-main -shared -package parsec -package dsp -static<br>
&gt;<br>
&gt; to this:<br>
&gt;<br>
&gt; HC_LOPTS = -shared -dynamic -package parsec-3.1.1 -package dsp -lHSrts<br>
&gt; -L/usr/lib/ghc-6.12.3/ -lm -lffi -lrt<br>
&gt;<br>
&gt; and things are working.<br>
&gt;<br>
&gt; (The command that builds my mixed language, shared object library,<br>
&gt; `libami.so&#39;, is:<br>
&gt;<br>
&gt; ghc -o libami.so $(HC_LOPTS) {object files, compiled from both C and Haskell}<br>
&gt; )<br>
&gt;<br>
&gt; I can understand why I&#39;d have to explicitly link against `libHSrts&#39;,<br>
&gt; since I&#39;m asking ghc for a shared object library and not an<br>
&gt; executable. However, I&#39;m not sure about the following:<br>
&gt; - Why do I need to give the `-L/usr/lib/ghc-6.12.3/&#39; option? (It seems<br>
&gt; like ghc ought to know about that, implicitly.)<br>
&gt; - Why do I need to explicitly link against the 3 standard C libraries:<br>
&gt; `m&#39;, `ffi&#39;, and `rt&#39;? (I&#39;ve never needed to do this, previously, when<br>
&gt; I was building/testing this project statically.)<br>
&gt;<br>
&gt; Thanks, in advance, for any insights!<br>
&gt;<br>
&gt; -db<br>
&gt;<br>
&gt;<br>
&gt; On 9/10/11, Sergiy Nazarenko &lt;<a href="mailto:nazarenko.sergiy@gmail.com">nazarenko.sergiy@gmail.com</a>&gt; wrote:<br>
&gt;&gt; I&#39;ve recompiled my library again and now it works without any problem.<br>
&gt;&gt; Probably I made mistake somewhere.<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Sergiy<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Haskell-Cafe mailing list<br>
&gt;&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Haskell-Cafe mailing list<br>
&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;<br>
</div></div></blockquote></div><br>