I am attempting to compile the Algorithm::SVM package on Win32. It's a wrapper for the LIBSVM library written using XS. It works wonderfully on gnu/linux, but when trying to link using g++ with cygwin or the mingw g++ I get a linker error along the lines of "undefined reference to _WinMain@16".

As suggested in the Cygwin FAQ I added an empty main function (int main() {return 0;}) to the sources, and everything compiled and linked. However, I think this introduced an "error" in to the resulting DLL. When attempting to load the library (i.e. the line use Algorithm::SVM) in my perl program, I get a segmentation fault.

Tracing the the execution in to the use Algorithm::SVM statment, I discovered that (using both the cygwin perl, and activestate perl), the segmentation fault occurs when executing the line &$xs(@args) in DynaLoader.pm.

My best guess is that adding the main function had some how corrupted the way the library is supposed to work. I have been attempting to compile the library with Visual C++ 6, and BCC 5.5, but it's turning out to be an arduous process, and I'm not sure if it will/can be successful. Not to mention that I would rather use free tools, if possible.

Is this a common problem when trying to get XS modules to work on windows? How is it usually corrected?


In reply to Compiling XS Libraries Suitable for DynaLoader on Win32 by torezodu

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.