Hi, Taro
Sorry for the late reply, thanks very much for your detailed report.
Your code diff is exactly the same as mine, and I tried your version of Perl
interpretor, too. However, the DLL still couldn't be loaded. I also googled
this problem, asked at irc.perl.org. Unfortunately, no answer have been
found yet. I even cannot run the test of an empty module generated by h2xs
on my Win32 :-( Maybe it has something to do with the version of MSVC? I'm
not sure and haven't tried. Anyhow, I uploaded the 0.12 version of the
module which could be successfully compiled by MSVC, hoping it will work for
you.
Thanks for your attention and help ^_^
Regards,
Laye
On Jan 28, 2008 7:58 PM, Taro Nishino via RT <
bug-Algorithm-LBFGS@rt.cpan.org> wrote:
>
> Queue: Algorithm-LBFGS
> Ticket <URL:
http://rt.cpan.org/Ticket/Display.html?id=32637 >
>
> Hi Laye,
>
> Thanks for your reply.
>
> > I wonder if this happens to you, too.
> The result of my testing is as follows:
>
> C:\test\Perl\Algorithm-LBFGS-0.11>nmake test
>
> Microsoft(R) Program Maintenance Utility Version 7.00.9955
> Copyright (C) Microsoft Corporation. All rights reserved.
>
> C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'in
> c', 'blib\lib', 'blib\arch')" t/01-parameter.t t/02-optimization.tt/03-monitor.
> t
> t/01-parameter.........ok
> t/02-optimization......ok
> t/03-monitor...........ok
> All tests successful.
> Files=3, Tests=12, 4 wallclock secs ( 0.03 usr + 0.05 sys = 0.08 CPU)
> Result: PASS
> ------------------------------------------------------------------------
>
> FYI, I attached my diff to this report.
> In addition, my Perl environment is as follows:
>
> C:\test\Perl\Algorithm-LBFGS-0.11>perl -V
> Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
> Platform:
> osname=MSWin32, osvers=5.0, archname=MSWin32-x86-multi-thread
> uname=''
> config_args='undef'
> hint=recommended, useposix=true, d_sigaction=undef
> usethreads=define use5005threads=undef useithreads=define
> usemultiplicity=de
> fine
> useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
> use64bitint=undef use64bitall=undef uselongdouble=undef
> usemymalloc=n, bincompat5005=undef
> Compiler:
> cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
> -D_CONSOLE -
> DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DUSE_SITECUSTOMIZE
> -DPERL_IMPLICIT_
> CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
> optimize='-MD -Zi -DNDEBUG -O1',
> cppflags='-DWIN32'
> ccversion='12.00.8804', gccversion='', gccosandvers=''
> intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
> d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
> ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
> lseeksi
> ze=8
> alignbytes=8, prototype=define
> Linker and Libraries:
> ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
> -libpath:"C:
> \Perl\lib\CORE" -machine:x86'
> libpth=\lib
> libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32
> .lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib
> uuid.lib ws2_
> 32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
> perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comd
> lg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib
> uuid.lib
> ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib
> msvcrt.lib
> libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
> gnulibc_version=''
> Dynamic Linking:
> dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
> cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
> -opt:ref,icf -
> libpath:"C:\Perl\lib\CORE" -machine:x86'
>
>
> Characteristics of this binary (from libperl):
> Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
> PERL_IMPLICIT_SYS PERL_MALLOC_WRAP
> PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES
> USE_PERLIO USE_SITECUSTOMIZE
> Locally applied patches:
> ActivePerl Build 817 [257965]
> Iin_load_module moved for compatibility with build 806
> PerlEx support in CGI::Carp
> Less verbose ExtUtils::Install and Pod::Find
> Patch for CAN-2005-0448 from Debian with modifications
> Partly reverted 24733 to preserve binary compatibilty
> 27528 win32_pclose() error exit doesn't unlock mutex
> 27527 win32_async_check() can loop indefinitely
> 27515 ignore directories when searching @INC
> 27359 Fix -d:Foo=bar syntax
> 27210 Fix quote typo in c2ph
> 27203 Allow compiling swigged C++ code
> 27200 Make stat() on Windows handle trailing slashes correctly
> 27194 Get perl_fini() running on HP-UX again
> 27133 Initialise lastparen in the regexp structure
> 27034 Avoid "Prototype mismatch" warnings with autouse
> 26970 Make Passive mode the default for Net::FTP
> 26921 Avoid getprotobyname/number calls in IO::Socket::INET
> 26897,26903 Make common IPPROTO_* constants always available
> 26670 Make '-s' on the shebang line parse -foo=bar switches
> 26379 Fix alarm() for Windows 2003
> 26087 Storable 0.1 compatibility
> 25861 IO::File performace issue
> 25084 long groups entry could cause memory exhaustion
> 24699 ICMP_UNREACHABLE handling in Net::Ping
> Built under MSWin32
> Compiled at Mar 20 2006 17:54:25
> @INC:
> C:/Perl/lib
> C:/Perl/site/lib
> .
>
> Thanks,
> Taro
>
>
> On Mon, 28 Jan 2008 02:12:30 -0500
> "laye@cpan.org via RT" <bug-Algorithm-LBFGS@rt.cpan.org> wrote:
>
> >
> > <URL:
http://rt.cpan.org/Ticket/Display.html?id=32637 >
> >
> > Dear Taro,
> >
> > Thanks very much for your love on this module.
> >
> > I've modified the module according to your suggestion, now it can be
> > successfully built in Win32 5.1 with Perl 5.10.0 and VS 2005.
> >
> > However, I failed in `nmake test', as DynaLoader refused to load the DLL
> > which is built from the XS.
> >
> > It croaks:
> >
> > C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e"
> "test_harness(0,
> > 'in
> > c', 'blib\lib', 'blib\arch')" t/01-parameter.t t/02-
> optimization.tt/03-monitor.
> > t
> > t/01-parameter.......Can't load
> > 'D:\var\Algorithm-LBFGS\blib\arch/auto/Algorithm
> > /LBFGS/LBFGS.dll' for module Algorithm::LBFGS: load_file:The specified
> > module co
> > uld not be found at C:/Perl/lib/DynaLoader.pm line 201.
> > at D:\var\Algorithm-LBFGS\blib\lib/Algorithm/LBFGS.pm line 12
> > BEGIN failed--compilation aborted at
> > D:\var\Algorithm-LBFGS\blib\lib/Algorithm/L
> > BFGS.pm line 12.
> > Compilation failed in require at t/LBFGS.pm line 16.
> > BEGIN failed--compilation aborted at t/LBFGS.pm line 16.
> > Compilation failed in require at t/01-parameter.t line 4.
> > BEGIN failed--compilation aborted at t/01-parameter.t line 4.
> > t/01-parameter.......dubious
> > Test returned status 2 (wstat 512, 0x200)
> >
> > I wonder if this happens to you, too.
> >
> > Thanks in advance.
> >
> > Happy hacking,
> > Laye
> >
>
>
> --- LBFGS.xs Thu Jan 24 12:56:17 2008
> +++ ALBFGS.xs Fri Jan 25 07:53:43 2008
> @@ -55,6 +55,9 @@
> const lbfgsfloatval_t step)
> {
> int i;
> + SV** args;
> + SV** rets;
> + lbfgsfloatval_t f;
> /* fetch refs to user evaluating sub and extra data */
> SV* lbfgs_eval = ((SV**)instance)[0];
> SV* user_data = ((SV**)instance)[2];
> @@ -63,8 +66,8 @@
> av_extend(av_x, n - 1);
> for (i = 0; i < n; i++) av_store(av_x, i, newSVnv(x[i]));
> /* allocate space for arguments and return values */
> - SV** args = (SV**)malloc(3 * sizeof(SV*));
> - SV** rets = (SV**)malloc(2 * sizeof(SV*));
> + args = (SV**)malloc(3 * sizeof(SV*));
> + rets = (SV**)malloc(2 * sizeof(SV*));
> /* call the user evaluating sub */
> args[0] = sv_2mortal(newRV_inc((SV*)av_x));
> args[1] = sv_2mortal(newSVnv(step));
> @@ -73,7 +76,7 @@
> /* get the function value and gradient vector from return values */
> for (i = 0; i < n; i++)
> g[i] = SvNV(*av_fetch((AV*)SvRV(rets[1]), i, 0));
> - lbfgsfloatval_t f = SvNV(rets[0]);
> + f = SvNV(rets[0]);
> /* release space of arguments and return values */
> SvREFCNT_dec(rets[0]);
> SvREFCNT_dec(rets[1]);
> @@ -96,17 +99,22 @@
> int ls)
> {
> int i;
> + AV* av_g;
> + SV** args;
> + SV** rets;
> + AV* av_x;
> + int r;
> /* fetch refs to the user progress monitor sub and extra data */
> SV* lbfgs_prgr = ((SV**)instance)[1];
> SV* user_data = ((SV**)instance)[2];
> /* create mortal AVs for C array x and g */
> - AV* av_x = (AV*)sv_2mortal((SV*)newAV());
> + av_x = (AV*)sv_2mortal((SV*)newAV());
> for (i = 0; i < n; i++) av_store(av_x, i, newSVnv(x[i]));
> - AV* av_g = (AV*)sv_2mortal((SV*)newAV());
> + av_g = (AV*)sv_2mortal((SV*)newAV());
> for (i = 0; i < n; i++) av_store(av_g, i, newSVnv(g[i]));
> /* allocate space for arguments and return values */
> - SV** args = (SV**)malloc(9 * sizeof(SV*));
> - SV** rets = (SV**)malloc(1 * sizeof(SV*));
> + args = (SV**)malloc(9 * sizeof(SV*));
> + rets = (SV**)malloc(1 * sizeof(SV*));
> /* call the user progress monitor sub */
> args[0] = sv_2mortal(newRV_inc((SV*)av_x));
> args[1] = sv_2mortal(newRV_inc((SV*)av_g));
> @@ -119,7 +127,7 @@
> args[8] = user_data;
> call_perl_sub(lbfgs_prgr, args, rets, 9, 1);
> /* get status from return value */
> - int r = SvIV(rets[0]);
> + r = SvIV(rets[0]);
> /* release space of arguments and return values */
> SvREFCNT_dec(rets[0]);
> free(args);
> @@ -225,16 +233,20 @@
> void* param
> void* instance
> SV* x0
> + PREINIT:
> + AV* av_x0;
> + int n;
> + lbfgsfloatval_t* carr_x0;
> + int i;
> + int s;
> CODE:
> /* build C array carr_x0 from Perl array ref x0 */
> - AV* av_x0 = (AV*)SvRV(x0);
> - int n = av_len(av_x0) + 1;
> - lbfgsfloatval_t* carr_x0 = (lbfgsfloatval_t*)
> - malloc(n * sizeof(lbfgsfloatval_t));
> - int i;
> + av_x0 = (AV*)SvRV(x0);
> + n = av_len(av_x0) + 1;
> + carr_x0 = (lbfgsfloatval_t*) malloc(n * sizeof(lbfgsfloatval_t));
> for (i = 0; i < n; i++) carr_x0[i] = SvNV(*av_fetch(av_x0, i, 0));
> /* call L-BFGS */
> - int s = lbfgs(n, carr_x0, NULL,
> + s = lbfgs(n, carr_x0, NULL,
> SvOK(((SV**)instance)[0]) ? &lbfgs_evaluate : NULL,
> SvOK(((SV**)instance)[1]) ? &lbfgs_progress : NULL,
> instance, (lbfgs_parameter_t*)param);
>
>