XSUB example in perlxstut fails to build on Win32

XSUB example in perlxstut fails to build on Win32

am 10.06.2005 04:40:30 von Richard Trahan

I'm trying to build the Mytest example in the perlxstut document. I'm
using ActivePerl build 811 and MinGW32-make. I get the error message "No
rule to make target 'C:\Perl\lib^', needed by 'Makefile'.

This error appears on a Cygwin bb, but without a solution.

Other attempts to hand-code examples from the perlxs document result in
errors like "unable to load "; this type of error has
been reported several times, also without a solution.

I'd like to hear from anyone who has gotten anything at all to work
using XS on Win32.

Re: XSUB example in perlxstut fails to build on Win32

am 10.06.2005 05:29:04 von Sisyphus

"Richard Trahan" wrote in message
news:L37qe.12966$hg.5051@fe12.lga...
> I'm trying to build the Mytest example in the perlxstut document. I'm
> using ActivePerl build 811 and MinGW32-make. I get the error message "No
> rule to make target 'C:\Perl\lib^', needed by 'Makefile'.
>
> This error appears on a Cygwin bb, but without a solution.
>

Don't use MinGW32-make. I doubt that the command 'perl Makefile.PL' is
capable of building a makefile that MinGW32-make can understand - even if
Config.pm were altered so that 'perl -V:make' reported 'MinGW32-make' (but I
haven't tested that).

Use either 'nmake' or 'dmake' - both of which are freely available.

Dmake from:
http://search.cpan.org/CPAN/authors/id/S/SH/SHAY/dmake-4.4-2 0050606-SHAY.zip

Nmake from:
http://download.microsoft.com/download/vc15/Patch/1.52/W95/E N-US/Nmake15.exe
or:
ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe

(After you download Nmake15.exe you need to run it, to install 'nmake'exe'
into the location of your choice.)

Dmake was buggy with some of the later examples in perlxstut, but those bugs
have supposedly been fixed in the version linked to above.

If you're using MS Visual Studio compiler and 'dmake' (which would be a
strange choice, as 'nmake' is part of Visual Studio), you would need to
alter Config.pm so that $Config{make} is set to 'dmake'.

If you're using the MinGW compiler with ActiveState perl, then you'll need
to install ExtUtils::FakeConfig from cpan (follow the instructions in the
README). Once you have done that, it's a good idea to 'set
perl5opt=-MConfig_m'. That way you don't need to enter 'perl -MConfig_m'
every time you want to run perl - ie you can just run (eg) 'perl
Makefile.PL' as you normally would and it will use the Config_m.pm values.

You should then be able to work your way through the tutorial (and build
perl extensions for your build 811 perl, too).

Another option is to build perl from cpan source using 'dmake' (use 'nmake'
*only* with Microsoft compilers when building perl) and your MinGW compiler.
It's a fairly straightforward procedure - see the file README.win32 in the
perl source distro. Actually, all I ever do is rename 'win32/Makefile' so
it doesn't get found by mistake, edit the configurable section of
'win32/makefile.mk' (accepting all defaults except those relating to the
perlinstall location and the location of my MinGW compiler), then run 'dmake
test', followed by 'dmake install'.This will avoid the need to install
ExtUtils::FakeConfig and mess around with any environment variables. But
ExtUtils::FakeConfig is easy to install and provides good milage, so it may
be simpler to stick with it for starters.

Cheers,
Rob

Re: XSUB example in perlxstut fails to build on Win32

am 10.06.2005 13:15:24 von Richard Trahan

Sisyphus wrote:
> "Richard Trahan" wrote in message
> news:L37qe.12966$hg.5051@fe12.lga...
>

(snip)

>
> Don't use MinGW32-make. I doubt that the command 'perl Makefile.PL' is
> capable of building a makefile that MinGW32-make can understand - even if
> Config.pm were altered so that 'perl -V:make' reported 'MinGW32-make' (but I
> haven't tested that).
>
> Use either 'nmake' or 'dmake' - both of which are freely available.
>
(snip)

Thank you for pointing me to these.

I've been playing with nmake all night, as I'm a bit familiar with it
from old C++ days. I've made further progress and can build the dll, but
it won't run.

I'm trying to stick with gcc and gnu ld because I don't want to be
dependent on the MS compiler. This necessitated substantial editing of
the Makefile.pl-generated makefile, as gcc/ld doesn't understand half
the options, and libraries have to be listed as archives, etc. I finally
got the dll to build, after taking two hours to discover that my Windows
Explorer options were set to hide system files (like dll).

When I run the hello.c program, I get a dll initialization failure at
DynaLoader.pm, line 230. That code is under the hood and over my head.
Any ideas? Thanks.

Re: XSUB example in perlxstut fails to build on Win32

am 10.06.2005 21:14:48 von Sisyphus

"Richard Trahan" wrote in message
news:rCeqe.23561$HP1.8218@fe08.lga...

>
> I've been playing with nmake all night, as I'm a bit familiar with it
> from old C++ days. I've made further progress and can build the dll, but
> it won't run.
>

You shouldn't need to be familiar with 'nmake' beyond knowing how to spell
it :-)

> I'm trying to stick with gcc and gnu ld because I don't want to be
> dependent on the MS compiler. This necessitated substantial editing of
> the Makefile.pl-generated makefile, as gcc/ld doesn't understand half
> the options, and libraries have to be listed as archives, etc. I finally
> got the dll to build, after taking two hours to discover that my Windows
> Explorer options were set to hide system files (like dll).
>

Generally, things should just work without having to do any editing or
debugging. If it's not working trivially, then you haven't got things set up
correctly.

> When I run the hello.c program, I get a dll initialization failure at
> DynaLoader.pm, line 230. That code is under the hood and over my head.

I don't know what dll or hello.c program you're talking about.

What happens when you try to build a module from cpan ? Try, for example,
building Math::FFT - and report errors back to us.

Cheers,
Rob

Re: XSUB example in perlxstut fails to build on Win32

am 10.06.2005 22:31:22 von Richard Trahan

Sisyphus wrote:

>
>
> Generally, things should just work without having to do any editing or
> debugging. If it's not working trivially, then you haven't got things set up
> correctly.
(snip)

For example, gcc chokes on -Gf, -Zi, -nologo, -W3, and -machine. These
have to be removed except for the last, which is changed to -mi386pe.
The cl -opt switch is interpreted as a file output switch by gcc. All
the makefile linker libs are .lib files, but the MinGW versions are in
archive format. The cl -dll flag must be --dll for gcc. The c object
extension for cl is .obj; for gcc is is .o (ld does not recognize .obj).
gcc does not recognize ref and icf optimization.
>
(snip)


> I don't know what dll or hello.c program you're talking about.

Sorry, I meant hello.pl. I should have retained something from the
original post. I'm trying to build the very first example in perlxstut,
which has a Mytest module and is driven by hello.pl.
>
> What happens when you try to build a module from cpan ? Try, for example,
> building Math::FFT - and report errors back to us.

I'll do that, but I know I won't get anywhere. My problems are more
basic (like lack of knowledge).

Perl developers come from a UNIX tradition, so it is understandable that
everything revolves around UNIX make. Don't you think that by now things
would have migrated to platform-independent langauge products, like
those of gnu? The makefile generated by h2xs is not understood by MinGW,
and nmake requires a Microsoft compiler and linker. I have the Visual
C++ development kit, but I refuse to exhume it on general principle.

I've been working on this XS business on and off for years, and have
never gotten anything to work. Are you running on a Win32 OS? Can you
post a minimal set of .xs, .pm, and .pl files that actually work?

Re: XSUB example in perlxstut fails to build on Win32

am 11.06.2005 01:21:03 von Robert Jordan

Richard,

> Perl developers come from a UNIX tradition, so it is understandable that
> everything revolves around UNIX make. Don't you think that by now things
> would have migrated to platform-independent langauge products, like
> those of gnu? The makefile generated by h2xs is not understood by MinGW,
> and nmake requires a Microsoft compiler and linker. I have the Visual
> C++ development kit, but I refuse to exhume it on general principle.

h2xs doesn't generate makefiles. It generates a nifty file
called Makefile.PL. That's the interface XSUB programmers iteract
with (docs: perldoc ExtUtils::MakeMaker).

The platform dependend makefile is generated by ExtUtils::MakeMaker
with instructions taken from Makefile.PL. Just call
"perl Makefile.PL". (Real ;-) XSUB programmers never change
the generated makefile. Nor they have to know more about
"make" then its name.

Now the rules: you should *always* use the compiler that
was used to compile perl itself. For ActiveState it's MSC,
part of Visual Studio. A free version exists as well.

Everything else is just wasting your time. If you don't
want/like MS' compilers, don't get a precompiled Perl that
was build with the products of that company.

> I've been working on this XS business on and off for years, and have
> never gotten anything to work. Are you running on a Win32 OS? Can you
> post a minimal set of .xs, .pm, and .pl files that actually work?

If you follow the rule above you should be able to build
every module, as far its XSUB part is portable.

Rob

Re: XSUB example in perlxstut fails to build on Win32

am 11.06.2005 04:21:27 von Sisyphus

"Richard Trahan" wrote in message
>
> For example, gcc chokes on -Gf, -Zi, -nologo, -W3, and -machine. These
> have to be removed except for the last, which is changed to -mi386pe.
> The cl -opt switch is interpreted as a file output switch by gcc. All
> the makefile linker libs are .lib files, but the MinGW versions are in
> archive format. The cl -dll flag must be --dll for gcc. The c object
> extension for cl is .obj; for gcc is is .o (ld does not recognize .obj).
> gcc does not recognize ref and icf optimization.

Installing ExtUtils::FakeConfig and running perl with the -MConfig_m option
will take care of all that for you. Or, alternatively, if you build your
perl with dmake and gcc (MinGW), those problems will not arise (because the
Config.pm that gets built will hold values appropriate for the compiler you
used).
The basic problem is that *your* Config.pm still contains a lot of stuff
that's pertinent only to Microsoft compilers. That "stuff" needs to be
replaced with "stuff" that's pertinent to the gcc compiler - and that's what
ExtUtils::FakeConfig does for you.

> > What happens when you try to build a module from cpan ? Try, for
example,
> > building Math::FFT - and report errors back to us.
>
> I'll do that, but I know I won't get anywhere. My problems are more
> basic (like lack of knowledge).
>

It's just that it's easier for us to troubleshoot using some readily
available cpan module, than using the perlxstut examples. And once you're
able to build extensions (such as Math::FFT) then you should be able to
successfully work your way through perlxstut.

Cheers,
Rob

D:\comp58_M>cd math-fft-0.26

D:\comp58_M\Math-FFT-0.26>perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Math::FFT

D:\comp58_M\Math-FFT-0.26>dmake test
cp FFT.pm blib\lib\Math\FFT.pm
D:\perl58_M\5.8.7\bin\perl.exe
:\perl58_M\5.8.7\lib\ExtUtils/xsubpp -typemap
D:\perl58_M\5.8.7\lib\ExtUtils\typemap -typemap typemap FFT.xs > FFT.xsc &&
D:\p
erl58_M\5.8.7\bin\perl.exe -MExtUtils::Command -e mv FFT.xsc FFT.c
Please specify prototyping behavior for FFT.xs (see perlxs manual)
gcc -c -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DP
ERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVCRT_READFIX -s -O2 -DVERS
ION=\"0.26\" -DXS_VERSION=\"0.26\" "-ID:\perl58_M\5.8.7\lib\CORE"
FFT.c
gcc -c -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DP
ERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVCRT_READFIX -s -O2 -DVERS
ION=\"0.26\" -DXS_VERSION=\"0.26\" "-ID:\perl58_M\5.8.7\lib\CORE"
fft4g.c
gcc -c -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DP
ERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVCRT_READFIX -s -O2 -DVERS
ION=\"0.26\" -DXS_VERSION=\"0.26\" "-ID:\perl58_M\5.8.7\lib\CORE"
arrays.c
Running Mkbootstrap for Math::FFT ()
D:\perl58_M\5.8.7\bin\perl.exe -MExtUtils::Command -e chmod 644 FFT.bs
D:\perl58_M\5.8.7\bin\perl.exe -MExtUtils::Mksymlists \
-e "Mksymlists('NAME'=>\"Math::FFT\", 'DLBASE' => 'FFT', 'DL_FUNCS' =>
{ }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);"
dlltool --def FFT.def --output-exp dll.exp
g++ -o
blib\arch\auto\Math\FFT\FFT.dll -Wl,--base-file -Wl,dll.base -mdll -s -L"D:\
perl58_M\5.8.7\lib\CORE" -L"D:\MinGW\lib" FFT.o fft4g.o
arrays.o -Wl,--image-base,0x222a0000

D:\perl58_M\5.8.7\lib\CORE\libperl58.a -lmsvcrt -lmoldname -lkernel32 -luser
32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -ln
etapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 dll.exp
dlltool --def FFT.def --base-file dll.base --output-exp dll.exp
g++ -o
blib\arch\auto\Math\FFT\FFT.dll -mdll -s -L"D:\perl58_M\5.8.7\lib\CORE" -L"D
:\MinGW\lib" FFT.o fft4g.o arrays.o -Wl,--image-base,0x222a0000
D:\perl58_M\5.8.7\lib\CORE\libperl58.a -lmsvcrt -lmoldname -lkernel32 -luser
32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -ln
etapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 dll.exp
D:\perl58_M\5.8.7\bin\perl.exe -MExtUtils::Command -e chmod 755
blib\arch\auto\Math\FFT\FFT.dll
D:\perl58_M\5.8.7\bin\perl.exe -MExtUtils::Command -e cp FFT.bs
blib\arch\auto\Math\FFT\FFT.bs
D:\perl58_M\5.8.7\bin\perl.exe -MExtUtils::Command -e chmod 644
blib\arch\auto\Math\FFT\FFT.bs
D:\perl58_M\5.8.7\bin\perl.exe "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib\lib', 'blib\arch')" t\apps.t t\fft.t t\stats.t
t\apps.....ok
t\fft......ok
t\stats....ok
All tests successful.
Files=3, Tests=47, 3 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00 CPU)

D:\comp58_M\Math-FFT-0.26>dmake install
Installing D:\perl58_M\site\5.8.7\lib\auto\Math\FFT\FFT.dll
Installing D:\perl58_M\site\5.8.7\lib\auto\Math\FFT\FFT.bs
Files found in blib\arch: installing files in blib\lib into architecture
dependent library tree
Installing D:\perl58_M\site\5.8.7\lib\Math\FFT.pm
Writing D:\perl58_M\site\5.8.7\lib\auto\Math\FFT\.packlist
Appending installation info to D:\perl58_M\5.8.7\lib/perllocal.pod

Re: XSUB example in perlxstut fails to build on Win32

am 12.06.2005 03:46:48 von Sisyphus

"Robert Jordan" wrote in message
news:d8d790$abq$02$1@news.t-online.com...

>
> Now the rules: you should *always* use the compiler that
> was used to compile perl itself.

That *was* true ... but ExtUtils::FakeConfig provides one with the
opportunity to use either nmake or dmake with the MinGW (gcc) compiler and
ActiveState perl.

I prefer to build perl from source with the MinGW compiler instead - but the
ExtUtils::FakeConfig alternative is definitely viable.

Cheers,
Rob

Re: XSUB example in perlxstut fails to build on Win32

am 21.06.2005 03:58:27 von Richard Trahan

Sisyphus wrote:
> "Richard Trahan" wrote in message
> news:L37qe.12966$hg.5051@fe12.lga...
>
(snip)

>
> If you're using the MinGW compiler with ActiveState perl, then you'll need
> to install ExtUtils::FakeConfig from cpan
(snip)

I tried installing ExtUtils::FakeConfig from ActiveState. Here's what I got:

ppm> install ExtUtils::FakeConfig
Error: No valid repositories:
Error: Can't locate unicore/Exact.pl in @INC (@INC contains: C:/Perl/lib
C:/Perl
/site/lib .) at C:/Perl/lib/utf8_heavy.pl line 108, line 1.
xmlns:SOAP-ENC="http://
schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlso
ap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3
..org/1999/XMLSchema"> xmlns:namesp1=
"urn:/PPMServer/"> xsi:type="SOAP-ENC:base64">UFBNIDIwMQ==

Error: Can't locate unicore/Exact.pl in @INC (@INC contains: C:/Perl/lib
C:/Perl
/site/lib .) at C:/Perl/lib/utf8_heavy.pl line 108, line 1.
xmlns:SOAP-ENC="http://
schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlso
ap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3
..org/1999/XMLSchema"> xmlns:namesp1=
"urn:/PPM/Server/SQL/">PPM
303
esp1:ppm_protocolResponse>


This stuff is way over my head. I never had a problem with ppm before,
either. Any help, please.

Re: XSUB example in perlxstut fails to build on Win32

am 21.06.2005 09:07:07 von Sisyphus

"Richard Trahan" wrote in message
news:4uKte.2230$Q05.380@fe08.lga...
> Sisyphus wrote:
> > "Richard Trahan" wrote in message
> > news:L37qe.12966$hg.5051@fe12.lga...
> >
> (snip)
>
> >
> > If you're using the MinGW compiler with ActiveState perl, then you'll
need
> > to install ExtUtils::FakeConfig from cpan
> (snip)
>
> I tried installing ExtUtils::FakeConfig from ActiveState. Here's what I
got:
>
> ppm> install ExtUtils::FakeConfig

[snip]

Well ..... I did say "install ExtUtils::FakeConfig from cpan", not "install
ExtUtils::FakeConfig from ActiveState". (ActiveState don't have a ppm for
it.)

To download the cpan distro click on:
http://search.cpan.org/CPAN/authors/id/M/MB/MBARBON/ExtUtils -FakeConfig-0.06.zip

Just follow the instructions in the Readme.txt that's part of that zipfile.
If you already have 'nmake.exe' in your path, and have added the MinGW\bin
location to your path, then it should be trivial. To ensure that both
'nmake' and the MinGW\bin files are in your path run:

nmake /?

and then:

gcc -v

If they don't error then things should be set for you to install
ExtUtils::FakeConfig:

Extract the zip file to some location, cd to that location (ie to the folder
that now contains the Readme.txt, along with other files) and run, in
succession:

perl makefile.pl
nmake
nmake install

Then you can build other perl extensions from cpan by running:

perl -MConfig_m makefile.pl
nmake
nmake test
nmake install

(Get hold of the Math::FFT module source from cpan and see if you can build
that extension.)

Cheers,
Rob