Skip Menu |

This queue is for tickets about the Net-Z3950-SimpleServer CPAN distribution.

Report information
The Basics
Id: 70447
Status: open
Priority: 0/
Queue: Net-Z3950-SimpleServer

People
Owner: Nobody in particular
Requestors: julian.esteves [...] janium.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.14
Fixed in: 1.14



Subject: Modifications needed for launching server on Win2008R2 with Strawberry Perl
Hello, I've managed to launch a server via Net::Z3950::SimpleServer (NZS) on Windows with Strawberry Perl!! I hope you find any of the following information useful and consider it for inclusion in next releases of NZS. First things first. I guess I must supply some context here. I'm sure I'll tell you some things you already know but please, bear with me, it's just for procedure's clarity sake. * Strawberry Perl (http://strawberryperl.com/) is our distribution of choice. The following was done on 5.12.1.0. * Among other things, Strawberry Perl includes MinGW GCC C/C++ compiler and Dmake "make" tool (http://win32.perl.org/wiki/index.php?title=Strawberry_Perl#Description). * But, unfortunately, that is not enough to have NZS compiled with a clean "perl Makefile.PL; make; make test; make install". * This is primarily because YAZ distribution does not include an "import library" in the format GCC expects it; it certainly includes a ".lib" library, but not a ".a". * But also some minor changes are needed in some NZS files to. So, off my two cents go... I. On having a libyaz.a usable with MinGW: 1. Install YAZ. Binaries and development are needed. Let's say they are installed on <YAZPATH>. [ Note: The following has been proved to work only on 4.2.6 for win64. but I guess it'll be the same on next releases. ] and 2. From a DOS command line, enter <YAZPATH>\bin and do: pexports yaz4.dll >yaz4.def [ Also a note here. This could of course be done on a PowerShell command line, but I've found that the resulting yaz4.def is encoded in UTF-16 and it then can't be used by "dlltool" in the next step without being decoded. ] and then do: dlltool.exe --input-def yaz4.def --dllname yaz4.dll --output-lib ../lib/libyaz.a It is essential that this two commands run without any error. 3. ** IMPORTANT ** In order to run any program linked against libyaz.a, <YAZPATH>\bin must be included in the PATH. [ - Sidebar - I guess it is possible to compile all of the YAZ suite "a la UNIX" with MinGW. For example, I've tested recompiling and launching the server included in "yaz-ztest.exe". Compilation went like this, with a command line in <YAZPATH>/ztest (for this it's necessary to install also YAZ source): gcc -c ztest.c -I ../include gcc -c read-marc.c -I ../include gcc -c dummy-opac.c -I ../include gcc -c read-grs.c -I ../include gcc -o yaz-ztest_mingw.exe ztest.o read-marc.o dummy-opac.o read-grs.o -L../lib -lyaz ] II. On having NZS usable with Strawberry Perl: 1. Download NZS from CPAN and enter the temporary folder containing it's source files: Show quoted text
cpan> get Net::Z3950::SimpleServer cpan> look Net::Z3950::SimpleServer
2. Edit Makefile.PL to set $yazinc and $yazlibs. [ Note: I'm attaching a modified Makefile.PL and a patch for your consideration. ] 3. Edit SimpleServer.xs so the correction needed to deal with "the PerlLIO_open issue" is done *before* the inclusion of yaz headers. [ Note: I'm also attaching a modified xs and a patch for it. ] 3.5 ;-) same as I.3 above... 4. Now compilation and installation can proceed as usual. perl Makefile.PL dmake dmake test dmake install [ Note: Testing phase on Windows will succeed with a modified version of test.pl. I'm attaching it and it's corresponding patch for your consideration as well. During that phase some info is required from the user. ] Thanks for reading up to here. I hope I've made myself (and my English) clear. Please let me know if you have any questions or comments. Regards, Julián Esteves <julian.esteves@janium.com>
Subject: files_and_patches.zip
Download files_and_patches.zip
application/zip 33.6k

Message body not shown because it is not plain text.

From: jesteves [...] janium.com
Hello again, Geez! I guess I pressed the "send" button too early... I forgot to call your attention to two things. In my particular case they were vital to have my Z39 server running on Windows. The first thing is noticeable in the modified version of "test.pl". It seems that for these programs to run under Windows (with Strawberry Perl) it is mandatory to declare the callback functions like this: INIT => "main::init_handler", FETCH => "main::fetch_handler" and *not* like this: INIT => \&main::init_handler, FETCH => \&main::fetch_handler With references the server seems not pass correct arguments to any of the handlers. As far as I saw, handlers received the arguments sent to launch_server() instead of the hashref was supposed to. And the second thing is *not* noticeable in test.pl. In the case of my server I was passing a global hash on GHANDLE during the call of new(), but it's value wasn't being supplied to handlers as supposed to. This issue was very difficult to debug. In fact, during some debugger (perl -d) sessions the GHANDLE returned as it should and everything went fine, but out of the debugger it was failure after failure... In some part it was this comment on SimpleServer.pm the one that made the hint for me: sub launch_server { my $self = shift; my @args = @_; ### This modal internal interface, in which we set a bunch of # globals and then call start_server(), is asking for # trouble. Instead, we should just pass the $self object # as a parameter into start_server(). if (defined($self->{GHANDLE})) { set_ghandle($self->{GHANDLE}); } I've just changed my code from my $global_hashref = {...}; my $zserver = new Net::Z3950::SimpleServer( GHANDLE => $global_hashref, INIT => 'main::init_handle', #... ); sub init_handle { my $args = shift; my $_hashref = $args->{GHANDLE}; #... } which was working perfectly well on Unix, to something like my $global_hashref = {...}; my $zserver = new Net::Z3950::SimpleServer( INIT => 'main::init_handle', #... ); sub init_handle { my $args = shift; my $_hashref = $main::global_hashref; #... } which seems to work fine both on Unix and Windows. Regards, Julián El Mar Ago 23 19:40:43 2011, jesteves@janium.com escribió: Show quoted text
> Hello, > > I've managed to launch a server via Net::Z3950::SimpleServer (NZS) on > Windows > with Strawberry Perl!! >
[...]