Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Okay, finally here is the solution to compiling external source GNU applications into your Perl source on Win32 systems using http://www.indigostar.com/perl2exe.htm compiler. My GNU applications came from an installation of cygwin http://unxutils.sourceforge.net/ or http://gnuwin32.sourceforge.net/

As per IndigoStar's manual page http://www.indigostar.com/pxman.htm you have to use the "-tiny" option when compiling your source.

perl2exe -tiny /path/to/your/source/code/source.pl
In your Perl source code you also have to add in commands to "include" the external dependent modules into your EXE at compile time.
#perl2exe_bundle "C:\cygwin\bin\find.exe" #perl2exe_bundle "C:\cygwin\bin\cygwin1.dll" #perl2exe_bundle "C:\cygwin\bin\cygintl-1.dll" my $this_dir = $ENV{TEMP} || $ENV{TMP} || ($^O eq "MSWin32" ? $ENV{WIN +DIR} : '/tmp');
For this example I'm importing GNU find.exe. The extra DLL's are required also by cygwin. If you run it without these DLL's compiled you get an error requesting you import them also. And yes the hash (#) at the beginning of the line is required.

The last line there is important, once its compiled how does your application know where the compiled components will reside at runtime? IndigoStar's compiler makes temporary copies of the imported programs to a temporary directory, which are removed at the end of execution. Where that temporary directory actually is for your system is based on this command, so use it yourself. Then in your code when you utilise the "find.exe" add this variable into your code so your program can find it.
open( FIND, "$this_dir\\find . -type d -print0 |" ) or die "can't run find: $!";
This will compile all the external dependencies into one exe, with a few extra dll's that are created because of the "-tiny" option. This is now fully portable to any other box, and doesn't require perl or cygwin installed. No more dependencies!!

Enjoy!
Dean

Programming these days takes more than a lone avenger with a compiler. - sam

In reply to Re: Re: Re: Importing external dependencies into source by crabbdean
in thread Importing external dependencies into source by crabbdean

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found