In case you don't want to mess with individual .o files, you can also use ExtUtils::MakeMakers's MYEXTLIB option to link against a static library (aka archive, thus extension .a), but you do need such a static library version of whatever secondary library dependencies you want to link the module's .so file against — a shared library (.so) file won't do.

As with OBJECT (suggested by Joost), you'd simply add MYEXTLIB => '/path/to/lib/foo/libfoo.a' (or MYEXTLIB => '/path/to/lib/foo/libfoo$(LIB_EXT)') to the WriteMakefile( ... ) options. That's essentially it.

During the make run, you should then see something like this (assuming your Perl/XS module is named MyFoo, which depends on libfoo...):

cc -shared MyFoo.o -o blib/arch/auto/MyFoo/MyFoo.so /path/to/lib/foo/l +ibfoo.a

This command creates a shared library MyFoo.so from the object file MyFoo.o and the other object files contained in libfoo.a (an archive is nothing but a collection of object files). In other words, your MyFoo.so is then statically linked against libfoo.

If all else fails, you can also edit the Makefile that's written by MakeMaker to issue something similar to the above command line (but keep in mind that any modifications will be lost when you rerun MakeMaker...)


In reply to Re: Real Static Modules by almut
in thread Real Static Modules by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.