Hi Sergiy,<br><br><i>>I thought having static library to solve my problem. And I'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'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>"... that would require all the static libraries
to have been built with <code class="literal">-fPIC</code> ...",<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"><<a href="mailto:nazarenko.sergiy@gmail.com">nazarenko.sergiy@gmail.com</a>></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'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 <<a href="mailto:capn.freako@gmail.com">capn.freako@gmail.com</a>> wrote:<br>
> Sergiy, Tom,<br>
><br>
> Thanks for your replies.<br>
><br>
> Sergiy, I was able to get this working without having to recompile my<br>
> installed Haskell libraries.<br>
><br>
> Tom, you were correct; I needed to explicitly link against the Haskell<br>
> run-time system, as well as a few other things:<br>
><br>
> I changed my ghc link options from this:<br>
><br>
> HC_LOPTS = -no-hs-main -shared -package parsec -package dsp -static<br>
><br>
> to this:<br>
><br>
> HC_LOPTS = -shared -dynamic -package parsec-3.1.1 -package dsp -lHSrts<br>
> -L/usr/lib/ghc-6.12.3/ -lm -lffi -lrt<br>
><br>
> and things are working.<br>
><br>
> (The command that builds my mixed language, shared object library,<br>
> `libami.so', is:<br>
><br>
> ghc -o libami.so $(HC_LOPTS) {object files, compiled from both C and Haskell}<br>
> )<br>
><br>
> I can understand why I'd have to explicitly link against `libHSrts',<br>
> since I'm asking ghc for a shared object library and not an<br>
> executable. However, I'm not sure about the following:<br>
> - Why do I need to give the `-L/usr/lib/ghc-6.12.3/' option? (It seems<br>
> like ghc ought to know about that, implicitly.)<br>
> - Why do I need to explicitly link against the 3 standard C libraries:<br>
> `m', `ffi', and `rt'? (I've never needed to do this, previously, when<br>
> I was building/testing this project statically.)<br>
><br>
> Thanks, in advance, for any insights!<br>
><br>
> -db<br>
><br>
><br>
> On 9/10/11, Sergiy Nazarenko <<a href="mailto:nazarenko.sergiy@gmail.com">nazarenko.sergiy@gmail.com</a>> wrote:<br>
>> I've recompiled my library again and now it works without any problem.<br>
>> Probably I made mistake somewhere.<br>
>><br>
>> Cheers,<br>
>> Sergiy<br>
>><br>
>> _______________________________________________<br>
>> Haskell-Cafe mailing list<br>
>> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
>><br>
><br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
><br>
</div></div></blockquote></div><br>