tachyon has asked for the wisdom of the Perl Monks concerning the following question:

Background: Macromedia have released a flashSDK which provides some C++ code and some binaries that allow you to convert Flash SWF files into HTML containing the text and links. I am making an XS wrapper using their C++ code so that you can easily do the conversion from within Perl with the plan of releasing it on CPAN.

Essentially the framework is very simple. They provide a Swf2HtmlConverterStdio class that has a ConvertSwf2Htm method which takes an input and output stream.

At the moment all I am trying to do is create/destroy the Class object. It all compiles fine on Linux with g++ but with cl.exe on Win32 it chokes on the line with a link error LNK2019: unresolved external symbol....

The XS I am using at the moment is stripped right down to just this:

#include "swf2html_stdio.h" #ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifdef __cplusplus } #endif MODULE = Flash PACKAGE = Flash Swf2HtmlConverterStdio * Swf2HtmlConverterStdio::new() void Swf2HtmlConverterStdio::DESTROY()

You can browse the code at: http://tachyon.perlmonk.org/Flash/ or download a tar.gz that contains the whole thing from http://tachyon.perlmonk.org/flash.tar.gz

The flashSDK is in ./inc along with its HTML README. The win32 issue is in WIN32_CHOKE.txt I don't do much C++ but assume it is something fairly simple that is not being included.

Any suggestions welcome.

cheers

tachyon

Replies are listed 'Best First'.
Re: C++ and XS compile issues on Win32
by PodMaster (Abbot) on Jun 03, 2004 at 02:42 UTC
    Get rid of the extern "C" stuff (apparently it's completely unneccessary and screws things up) and try again (you might need to add #include <stdlib.h> on top).

    update: Whenever I've encountered errors like WIN32_CHOKE.txt recompiling the library in question with perl -MExtUtils::Embed -e ccopts (the -MD option is what's important) usually does the trick .

    Also, FYI, 'XSOPT'         => '-C++', is a null op, and has been practically always (I checked).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Hi PodMaster thanks for the hints. I have come to the conclusion that XS, Win32, CL.EXE + C++ is a bad combination. With C things can generally be made work but C++. Aargh. While it is easy to build this SDK from within Visual studio as soon as you get out side it and want to do stuff off the command line all sorts of issues start arrising. All due to unresolved externals. I finally got sick of it when I hit an unresolved externals bug related to this MS compiler SNAFU. I don't need it to compile on Win32. I can compile on Linux so time to be practical.

      cheers

      tachyon