Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h2xs based on .h and .c files at windows #14828

Closed
p5pRT opened this issue Jul 29, 2015 · 12 comments
Closed

h2xs based on .h and .c files at windows #14828

p5pRT opened this issue Jul 29, 2015 · 12 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 29, 2015

Migrated from rt.perl.org#125720 (status was 'open')

Searchable as RT125720$

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From tal.segev@gmail.com

Extension based on .h & .c files as described at [1], does not work on
windows systems. I have tried to resolved that issue through Stackoverflow
[2], without success.

The bug accure on several windows system (all windows 7) 64bit and 32bit,
various of distributions, strawberryPerl and activePerl.
On Linux systems (I've tried two Raspbian & Kubuntu 14.04) It works.

I've added a test case at [3]

  1. http://perldoc.perl.org/h2xs.html#Extension-based-on-_.h_-and-_.c_-files
  2. http://stackoverflow.com/questions/31687904/h2xs-based-on-h-and-c-files-at-windows
  3. https://app.box.com/s/phf84zjocq0w38sk65v0wsaa05bhq7tr

Regards,
Tal Segev
​​

Linkedin http://goo.gl/aVYd9 | Dropbox http://goo.gl/mfGFt

Perl Info

Flags:
    category=utilities
    severity=medium

Site configuration information for perl 5.22.0:

Configured by strawberry-perl at Mon Jun  1 20:06:45 2015.

Summary of my perl5 (revision 5 version 22 subversion 0) configuration:

  Platform:
    osname=MSWin32, osvers=6.3, archname=MSWin32-x86-multi-thread-64int
    uname='Win32 strawberry-perl 5.22.0.1 #1 Mon Jun  1 20:04:50 2015 i386'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags =' -s -O2 -DWIN32  -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing
-mms-bitfields',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.9.2', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678,
doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8,
longdblkind=3
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='long
long', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE"
-L"C:\strawberry\c\lib"'
    libpth=C:\strawberry\c\lib C:\strawberry\c\i686-w64-mingw32\lib
C:\strawberry\c\lib\gcc\i686-w64-mingw32\4.9.2
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl522.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=xs.dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE"
-L"C:\strawberry\c\lib"'



@INC for perl 5.22.0:
    C:/Perl/perl/site/lib
    C:/Perl/perl/vendor/lib
    C:/Perl/perl/lib
    .


Environment for perl 5.22.0:
    CYGWIN=binmode ntsec
    HOME=C:\Users\at
    LANG (unset)
    LANGUAGE=en_US
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=C:\ProgramData\Oracle\Java\javapath;C:\ispLEVER_Classic1_8\ispcpld\bin;C:\ispLEVER_Classic1_8\ispFPGA\bin\nt;c:\Software\octave3.6.4\bin;C:\Program
Files\Qucs\bin;C:\Program Files\Common Files\Microsoft Shared\Windows
Live;C:\Program Files\PC Connectivity
Solution\;C:\Perl\site\bin;C:\Perl\bin;C:\perl\c\bin;C:\perl\perl\site\bin;C:\perl\perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\Windows Live\Shared;C:\Program Files\Bitvise Tunnelier;c:\Program
Files\trayrun;c:\Program Files\mplayer;C:\Program Files\sqLite\;c:\Program
Files\7-Zip\;c:\MinGW\bin;C:\WinAVR-20100110\bin;C:\WinAVR-20100110\utils\bin;c:\Program
Files\Java\jdk1.7.0_03\bin;c:\Program Files\Java\jre7\bin\;c:\Program
Files\Android\android-sdk\tools;c:\Program
Files\Java\Java_ME_platform_SDK_3.0.5\bin\;c:\Program
Files\Samsung_SDK_11\bin\;c:\Program Files\Oracle\JavaFX 2.0
SDK\bin\;c:\MinGW\extra\boost\boost_1_49_0\tools\build\v2\engine\bin.ntx86;c:\MinGW\extra\boost\boost_1_49_0\tools\build\v2\engine\bootstrap\;C:\Program
Files\Google\Google Apps Sync\;C:\Program Files\Google\Google Apps
Migration\;C:\Program Files\OpenVPN\bin;C:\Program Files\Bitvise SSH
Client;c:\progra~1\iverilog\bin;C:\Program Files\P-CAD 2006
Viewer\;C:\Program Files\QuickTime\QTSystem\;C:\Program
Files\Nmap;C:\Program
Files\Java\jre6\bin\client\;c:\altera\11.0sp1\modelsim_ase\win32aloem;C:\Program
Files\SDCC\bin
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @jkeenan

It's going to be difficult for people to evaluate this bug report because the source code is at [3].

Attached, please find my attempt at bunzipping and untarring that URL. If anyone can translate this into a more p5p-friendly bug report, please do so.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @jkeenan

test.bat

rem @echo Off
rem http://perldoc.perl.org/h2xs.html

call h2xs -Afn tst
copy tst123.* tst\
call h2xs -Oxan tst tst123.h
copy tst.t tst\t\
cd tst
perl Makefile.PL
dmake
dmake test
cd ..

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @jkeenan

test.sh

#!/bin/sh

#rem http://perldoc.perl.org/h2xs.html

h2xs -Afn tst
cp tst123.* tst/
h2xs -Oxan tst tst123.h
cp tst.t tst/t/
cd tst
perl Makefile.PL
make
make test
cd ..

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @jkeenan

# Before 'make install' is performed this script should be runnable with
# 'make test'. After 'make install' it should work as 'perl tst.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use strict;
use warnings;

use Test​::More tests => 3;

BEGIN { use_ok('tst') };
#########################

# Insert your test code below, the Test​::More module is use()ed here so read
# its man page ( perldoc Test​::More ) for help writing this test script.

can_ok('tst', qw(tstAdd));
is(6, tst​::tstAdd(3,3), 'tstAdd');

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @jkeenan

#include "tst123.h"

int tstAdd(int a,int b) {
   return a+b;
}

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

From @jkeenan

tst123.h

#ifndef __tst123_H_
#define __tst123_H_

int tstAdd(int,int);
#endif

@p5pRT
Copy link
Author

p5pRT commented Jul 29, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 31, 2015

From @bulk88

On VC Perl (note the OP is using GCC Perl), there is something wrong with Perl core.


C​:\sources\h2xs_test>call h2xs -Oxan tst tst123.h
Defaulting to backwards compatibility with perl 5.23.2
If you intend this module to be compatible with earlier perl versions, please
specify a minimum perl version with the -b option.

Overwriting existing tst!!!
Writing tst/ppport.h
Scanning typemaps...
Scanning c​:\perl521\lib/ExtUtils/typemap
Scanning tst123.h for functions...
'cppstdin' is not recognized as an internal or external command,
operable program or batch file.
'cppstdin' is not recognized as an internal or external command,
operable program or batch file.
Scanning tst123.h for typedefs...
Writing tst/lib/tst.pm
Writing tst/tst.xs
Writing tst/fallback/const-c.inc
Writing tst/fallback/const-xs.inc
Writing tst/Makefile.PL
Writing tst/README
Writing tst/t/tst.t
Writing tst/Changes
Writing tst/MANIFEST

C​:\sources\h2xs_test>


What is "cppstdin" script/app? INSTALL says


=head2 Installed files

If you want to see exactly what will happen without installing
anything, you can run

  ./perl installperl -n
  ./perl installman -n

make install will install the following​:

  binaries

  perl,
  perl5.n.n where 5.n.n is the current release number. This
  will be a link to perl.

  scripts

  cppstdin This is used by the deprecated switch perl -P,
  if your cc -E can't read from stdin.


What is exactly is capital -P? It was removed in 4c84d7f

Where is the cppstdin script?

The lines come from the canned config 356231b​:/win32/config.vc#l72
6643fc8

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2015

From @bulk88

On strawberry perl, the bug is the following

from C​::Scan


sub new {
  die "usage​: C​::Preprocessed->new(filename[, defines[, includes[, cpp]]])"
  if @​_ < 2 or @​_ > 5;
  my ($class, $filename, $Defines, $Includes, $Cpp)
  = (shift, shift, shift, shift, shift);
  $Cpp ||= \%Config​::Config;
  my $filedir = dirname $filename || '.';
  $Includes ||= [$filedir, '/usr/local/include', '.'];
  my $addincludes = "";
  $addincludes = "-I" . join(" -I", @​$Includes)
  if defined $Includes and @​$Includes;
  my($sym) = gensym;
  my $cmd = "echo '\#include \"$filename\"' | $Cpp->{cppstdin} $Defines $addincludes $Cpp->{cppflags} $Cpp->{cppminus} |";
  #my $cmd = "$Cpp->{cppstdin} $Defines $addincludes $Cpp->{cppflags} $Cpp->{cppminus} < $filename |";
  #my $cmd = "echo '\#include <$filename>' | $Cpp->{cppstdin} $Defines $addincludes $Cpp->{cppflags} $Cpp->{cppminus} |";

  (open($sym, $cmd) or die "Cannot open pipe from `$cmd'​: $!")
  and bless $sym => $class;
}


If I change

  my $cmd = "echo '\#include \"$filename\"' | $Cpp->{cppstdin} $Defines $addincludes $Cpp->{cppflags} $Cpp->{cppminus} |";

to

  my $cmd = "echo \#include \"$filename\" | $Cpp->{cppstdin} $Defines $addincludes $Cpp->{cppflags} $Cpp->{cppminus} |";

removing the single quotes, tst.xs looks correct by defining xsub tstAdd


#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <tst123.h>

#include "const-c.inc"

MODULE = tst PACKAGE = tst

INCLUDE​: const-xs.inc

int
tstAdd(arg0, arg1)
  int arg0
  int arg1


The bug was already reported at

https://rt.cpan.org/Public/Bug/Display.html?id=54863

but C​::Scan was last released in 2001, so nobody cares about h2xs or C​::Scan anymore.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2015

From @hvds

"bulk88 via RT" <perlbug-followup@​perl.org> wrote​:
[...]
:The bug was already reported at
:
:https://rt.cpan.org/Public/Bug/Display.html?id=54863
:
:but C​::Scan was last released in 2001, so nobody cares about h2xs or C​::Scan anymore.

I'm not sure if anyone thinks they're the maintainer - I did the last
release, to incorporate some features requested by Tim Bunce, but assumed
Ilya would continue as primary owner; however I'm not sure that he does
perl stuff any more.

If anyone is willing to maintain it, I for one would have no objection.

Hugo

@toddr
Copy link
Member

toddr commented Feb 13, 2020

This appears to be a bug report about a CPAN module. I'm closing this case as a result.

@toddr toddr closed this as completed Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants