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

Hello monks,

After converting my code to exe using perl2exe i get the following error.

PLEASE SEE THE PERL2EXE USER MANUAL UNDER "can't locate somemodule.pm in @INC FOR EXPLANATION OF THE FOLLOWING MESSAGE: can't locate Tk/Scrollbar.pm in @INC <@INC contains: ./lib PERL2EXE_STORAGE C:perl\p2x-8.82-win32 c:\DOCUME~1\laser\LOCAL~1\Temp/p2xtmp-984 .) at lib/PERL2EXE_STORAGE/auto/TK/Frame/AddScrollbars.al line 9.

Can anybody help me out of this

Update: Also i am using scrollbar in my code

Update: from google it told to add this code after use strict;

push @INC, sub { my (undef, $file) = @_; if ( $file !~ /^PERL2EXE_STORAGE/ ) { print "\n ADD THIS PRAGMA:\n"; print "#perl2exe_include \"$file\"\n\n"; } return undef; };

Update: After i added use Tk::Scrollbar; I got the display but still i got another error as which states PLEASE SEE THE PERL2EXE USER MANUAL UNDER "can't locate somemodule.pm in @INC FOR EXPLANATION OF THE FOLLOWING MESSAGE: can't locate utf8.pm in in @INC <@INC contains: ./lib PERL2EXE_STORAGE C:perl\p2x-8.82-win32 c:\DOCUME~1\laser\LOCAL~1\Temp/p2xtmp-984 . CODE(0x190ce90)) at C:perl\p2x-8.82-win32\vendor_work_front.exe line 258. BEGIN failed--compilation aborted. main::BEGIN at C:\Perl\p2x-8.82-Win32\vendor_work_front.exe line 258 main::ftp_start at C:\Perl\p2x-8.82-Win32\vendor_work_front.exe line 0 main::validate at C:\Perl\p2x-8.82-Win32\vendor_work_front.exe line 249 main::__ANON__ at C:\Perl\p2x-8.82-Win32\vendor_work_front.exe line 174 Tk callback for .button4 Tk::__ANON__ at PERL2EXE_STORAGE/Tk.pm line 252 Tk::Button::butUp at PERL2EXE_STORAGE/Tk/Button.pm line 111 <ButtonRelease-1> (command bound to event)

in line 258 i have this code $excelname =~ s/\\/\/\//gi; ## I use this to change the file path as c:\temp as c://temp will that be any problem monks

Update: should i add use utf8; in my code

Replies are listed 'Best First'.
Re: Perl/tk coversion to exe error
by moritz (Cardinal) on Jan 18, 2012 at 15:42 UTC
    PLEASE SEE THE PERL2EXE USER MANUAL UNDER "can't locate somemodule.pm in @INC FOR EXPLANATION OF THE FOLLOWING MESSAGE

    So, did you read the section of the user manual that the error message mentions? If yes, what problem remains? If not, why not?

Re: Perl/tk coversion to exe error
by Marshall (Canon) on Jan 18, 2012 at 15:45 UTC
    To help out the conversion process, add: "use Tk::Scrollbar;" to your code. This will cause the scrollbar stuff to be included in the .exe. When running outside of the .exe, this would be autoloaded when needed and all you need is a simple "use Tk;".

    Update: This is a common problem. You will have to test,rinse,repeat to find these runtime errors. After awhile, you will just automatically add a "use" statement when you employ some additional widget in the code. I use ActiveState's perlApp program to make .exe's. They have heuristics that look at the Tk methods to force widgets into the .exe. That's a nice feature, but their program costs some $bucks.

Re: Perl/tk coversion to exe error
by Marshall (Canon) on Jan 18, 2012 at 17:56 UTC
    re your update:
    When I said: "You will have to test, rinse, repeat to find these runtime errors.". That means that this is an iterative process! Sorry for the colloquial English. Now you need: "use Tk::Button;"

    If this is a large Tk application, this process will continue maybe for a dozen times? Sounds like my advice worked the first time - similar advice is going to work again...The ability to recognize patterns is an important part of SW.

    Of course it should go without saying that you shouldn't make an .exe out of code that doesn't run correctly to begin with.

    Update: re-worked my update - hope not confusing - Windows path - don't see a GUI issue here. UTF8 sounds like an issue. If you get a message when running the .exe: can't find XXX.pm, then "use XXX;": can't locate utf8.pm-> use UTF8;

    PS: I hope that you have abandoned the "google advice" and are using my suggestions. If you aren't then...I don't know what you are currently doing...The main thrust should be to eliminate these Tk errors by "using" the appropriate widgets.

Re: Perl/tk coversion to exe error
by Anonymous Monk on Jan 18, 2012 at 15:55 UTC

    The message couldn’t be more explicit ... so, go follow it.

    Perl has a well-defined system for searching for modules that are referenced in a program.   It also has the use modulename; statement to specifically identify those requirements.   It has use strict and use warnings.   All of these language features are extremely well-documented, and in just a few minutes of your own time you will surely encounter them and thereby resolve your problem.

      The issue here is that Scrolled is a method call that's buried in the source code. Perl doesn't know that method is not there until the code is actually executed. Adding a "use Tk::Scrollbar;" makes this explicit to the thing that makes the .exe and it will include every module that is "used". There are other command line options to force inclusion of a module, but I find adding this "normally unnecessary use statement" to the source code to be the easiest way.