[wxPerl] Spreadsheet::Read 사용시 실행프로그램이 죽는 문제

manabooks의 이미지

현재 64 bit MS Windows에서 구동될, Excel파일을 읽어 가공하는 실행 프로그램을 만들고 있습니다.
Console(CMD)에서 디버깅을 마치고 실행파일을 만들었는데, 실행파일이 중간에 죽어버려 해결책을 문의드리고자 글을 올리게 되었습니다.

[증상]
MS Windows 10 CMD에서
 perl Excel-Wx.pl
로 실행시키면 문제가 없이 작동하는데,

이 CODE를 아래와 같이 실행파일로 만들어 사용하면, Spreadsheet::Read의 ReadData()함수를 실행하면서 죽어버립니다.

D:\perl> wxpar --gui Excel-Wx.pl -o  Excel-Wx.exe
 
Running Command .....
 
pp @Excel-Wx.wxparargs --gui Excel-Wx.pl -o Excel-Wx.exe
 
 .....
 
D:\perl>

[개발환경]
프로그램 개발환경은 다음과 같습니다.

MS Windows 10 64bit, Intel i5-7400, 8 Gbyte RAM, 
Perl v5.26.1 for MSWin32-x64-multi-thread
(Strawberry Perl)

[CODE]
아래는 문제가 되는 CODE와 관련된 부분만 추려놓은 프로그램입니다.
아래 CODE의 파일명을 Excel-Wx.pl라고 할 때, MS Windows CMD에서
 perl Excel-Wx.pl
로 실행키면 정상적으로 작동합니다.

정상적으로 작동한다는 것은, "Load" 버튼을 눌러 xls파일을 열어도 프로그램이 죽는 않는 것입니다.(그래야 열린 xls파일을 읽어서 다음 작업을 수행할 수 있습니다.)

반면,
wxpar --gui Excel-Wx.pl -o  Excel-Wx.exe
로 생성한 실행파일인 "Excel-Wx.exe"를 마우스로 클릭하여 실행시키면, "Load" 버튼을 눌러 xls파일을 여는 순간 프로그램이 종료되어 버립니다.

use Wx::Perl::Packager; # wxpar --gui Excel-Wx.pl -o  Excel-Wx.exe
 
use strict;
use warnings;
use utf8; 
use Spreadsheet::Read qw(ReadData);
use File::Basename;
use Encode;
 
use Wx;
use Wx qw(:everything);
use Wx::Event qw(EVT_MENU EVT_BUTTON);
 
my $App = Wx::SimpleApp->new;
 
my $frame = Wx::Frame -> new(
    undef,  #Label
    -1, #ID 
    "",#frame name
    [50,50], # position x, y
    [300,150],# width, height
    wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX #Default
    );
 
my $xoff=10 ; my $yoff1=10 ;
 
### Part1###
#Button Widget 
my $button1 = Wx::Button->new(
    $frame, 
    -1, #ID 
    'Load', # Button label
    [0+$xoff,0+$yoff1] # position x, y
    );
#Button1 Event
EVT_BUTTON(
    $frame, 
    $button1, #Button 
    \&button1_event #event function
    );
 
$frame -> Show(); $App -> MainLoop  ();
 
########
my $Path1; my $File1; my $XLS1; 
 
# button1 Event
sub button1_event{ 
    my $pre_dir ="./";	my $pre_file='';	
	my( $self, $event ) = @_;	
 
	my $dialog = Wx::FileDialog->new ( 
			$self,
			"Load",  # Title
			$pre_dir, $pre_file,
		  "|*.xls*|All files (*.*)", 
		  wxFD_OPEN  | wxFD_MULTIPLE 
	);      
 
	if( $dialog->ShowModal != wxID_CANCEL ) {
			$Path1 = $dialog->GetPath;
			$File1 = basename($Path1) ;
			$Path1 =  encode( 'cp949', $Path1 ); # MS Windows 
 
			$XLS1 = ReadData( $Path1 ) ;  #문제의 CODE
	}
}
shint의 이미지

대충 해보것 정리합니다. ㅇ_ㅇ;;

- Strawberry 에서 cpan Wx 설치가 안되네요. ㅇ_ㅇ;;

if not exist gcc_mswudll mkdir gcc_mswudll
process_begin: CreateProcess(NULL, C:/Windows/system32/ -c "if not exist gcc_mswudll mkdir gcc_mswudll", ...) failed.
make (e=5): 액세스가 거부되었습니다.
gmake: [makefile.gcc:5089: gcc_mswudll] Error 5 (ignored)
if not exist ..\..\lib\gcc_dll mkdir ..\..\lib\gcc_dll
process_begin: CreateProcess(NULL, C:/Windows/system32/ -c "if not exist ..\..\lib\gcc_dll mkdir ..\..\lib\gcc_dll", ...) failed.
make (e=5): 액세스가 거부되었습니다.
gmake: *** [makefile.gcc:5639: ..\..\lib\gcc_dll] Error 5
system: gmake -f makefile.gcc all UNICODE=1 MSLU=0 BUILD=release SHARED=1 DEBUG_INFO=default DEBUG_FLAG=1 LDFLAGS=" -m64" CPPFLAGS="-m64": 512 at inc/My/Build/Win32.pm line 284.
MDOOTSON/Alien-wxWidgets-0.69.tar.gz
C:\Strawberry\perl\bin\perl.exe ./Build -- NOT OK
Stopping: 'install' failed for 'Alien::wxWidgets'.

- Bareword "XXXDLLSXXX" not allowed while "strict subs" in use at C:/Strawberry/perl/lib/Wx/Mini.pm line 12.

- ActivePerl 에서 cpan Wx 설치는 되지만. 실행은 안됩니다.
- Spreadsheet::Read 와 Tk 로 엑셀 파일 읽기는 됩니다.
- PHP 에도 Spreadsheet_Excel_Reader 함수가 있습니다.
- pp 로 설치하는 방법이 있네요.
- Citrus Perl 을 덮어씌우니. 설치 제거도 잘 안됩니다. ㅇ_ㅇ;;

- wxpar 도 실행 안됩니다. ㅇ_ㅇ;;
- wxpar 에 대한 글을 보니. 실행시 값을 얻을 수 없는 경우가 있다고 합니다.

- 한줄씩 지워서. 내용을 출력해서. 확인해보세요. ㅇ_ㅇ;;
- 펄 사용자 모임과 깃 허브에도 문의해 보세요. ㅇ_ㅇ;;

댓글 첨부 파일: 
첨부파일 크기
Package icon [wxPerl] SpreadsheetRead.zip29.7 KB

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

manabooks의 이미지

- Wx 및 Wx::Perl::Packager설치
전 Strawberry-perl 설치 후 CMD에서 아래와 같이 설치했는데, 별다른 문제가 없었기에 shint님께서 말씀하신 Wx 설치 관련 문제에 대해서는 잘 모르겠습니다.

c:\>cpan
cpan> install Wx
cpan> install PAR::Packer
cpan> install Wx::Perl::Packager

상술한 설치가 정상적으로 진행되어야 wxpar을 쓸 수 있는 것 같습니다.

함께 고민해 주셔서 감사드립니다.

현재 전 aero's blog에 있는 "윈도우에서 Perl어플리케이션 배포" (http://aero2blog.blogspot.com/search?q=par)보며 실행파일을 컴파일하는 방식을 바꾸어 시도해 보고 있습니다.

혹시, 추후에라도 해결책을 찾게 되시면 본 게시물에 남겨주시길 부탁드립니다.

shint의 이미지

Tk 로 설치하면 Spreadsheet::Read 가 정상으로 보였는데.
알려주신 설치 방법은. 정상적으로 읽지 못하는 현상이 발생합니다. 뒤죽 박죽... ㅇ_ㅇ;;

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

manabooks의 이미지

자문자답이 되었는데, 발견한 해결책을 올려봅니다.

[방법]

1. 아래와 같이 CMD에서 명령을 내립니다. (Excel-Wx.pl이 C:\에 있다고 가정함)

C:\> wxpar --gui -x  --link=C:\Strawberry\c\bin\libexpat-1__.dll Excel-Wx.pl -o Excel-Wx.exe
 
Running Command .....
 
pp @beta.wxparargs --gui -x --link=C:\Strawberry\c\bin\libexpat-1__.dll Excel-Wx.pl -o Excel-Wx.exe
 
 .....

2. Excel-Wx.exe가 생성되기 전에 프로그램이 실행되면, 반듯이 *.xlsx인 파일을 FileDialog에서 하나 이상 열어봅니다.

3. 프로그램을 종료하면 Excel-Wx.exe가 생성되어있으며, 이것은 정상적으로 작동합니다.

[설명]
첫번째는, pp의 option 중 -x는 대화형 프로그램에서 사용자가 특정 기능을 작동시킬 때 발생하는 의존성을 검사해준다고 합니다.
(pp may be able to detect the use of modules that can't be determined by static analysis of inputfile - metacpan.org)
-x를 사용하면 wxpar 가 곧바로 exe파일을 생성하지 않고, 해당 소스코드의 프로그램을 띄워 사용자가 작동 후 종료할 때까지 대기하다가, 종료하면 packaging을 끝내고 exe파일을 생성합니다.

다음으로, NtTrace으로 해당 프로그램이 실행될 때 참조하는 DLL파일을 추적해보니, C:\Strawberry\c 아래의 파일 중 하나인 libexpat-1__.dll를 사용하는 것을 확인했습니다.
통상적으로는 C:\Strawberry\perl 내의 파일만 사용하기에 이것이 빠져서 문제를 일으키는 것으로 판단했습니다.
그래서 pp의 option 중 특정 DLL파일을 강제로 packaging에 포함시키는 --link를 사용했습니다.
(--link=C:\Strawberry\c\bin\libexpat-1__.dll)

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.