Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: h2xs on Windows

by Anonymous Monk
on Nov 22, 2011 at 15:04 UTC ( #939471=note: print w/ replies, xml ) Need Help??


in reply to h2xs on Windows

I tried using swig and failed. I also tried various h2xs tutorials and i still don't get anywhere. I can't use Inline::C because the target systems don't have compilers or a full Perl suite installed (using perlapp instead).

Yes, yes you can.

What Inline::C really does is write xs distribution for you

You can compile it, install it, make par ...

Tips via Exploring Inline::C (Generating primes)

use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'END_C', NAME => 'scriptname', CLEAN_AFTER_BUILD => + 0; END_C

See also perlxstut, Interfacing Perl with C++, using XS, with external files, and using the STL as parameters and return values. ...


Comment on Re: h2xs on Windows
Download Code
Re^2: h2xs on Windows
by cavac (Chaplain) on Nov 22, 2011 at 18:06 UTC

    Thank you. I think i nearly got it. I managed to adapt Example 4 of perlxstut.

    Only thing open is now a minor problem: In the main directory (not the library subdir) i also need to - in addition to link my library - link to opensc.dll. The correct flags for gcc are:

    -L. -lopensc

    Calling gcc manually with this flags works, after which i can finish whith another call to dmake. But i can't seem to find a way to tell MakeMaker that.

    Putting them into LIBS doesn't help. What am i missing here?

    Don't use '#ff0000':
    use Acme::AutoColor; my $redcolor = RED();
    All colors subject to change without notice.
      Putting them into LIBS doesn't help.

      How exactly did you specify it?  I'm not 100% sure about Windows, but normally, putting

      LIBS => "-L. -lopensc",

      in the WriteMakefile() call in Makefile.PL should work just fine (IIRC, MakeMaker would expand the "." to an absolute path).

      Did you see your -L/-l combo in the linking command issued when building the extension?  Did you get a warning like "Note (probably harmless): No library found for -lopensc" (in which case the respective LIBS spec would be removed from the link arguments)?

        LIBS => "-L. -lopensc",

        Yes, did that. MakeMaker complains that it has to expand the path and that it doesn't find opensc. But the dll is actually there:

        C:\src\chipcard_neu\opensc\Maplat-CCReader>perl Makefile.PL Set up gcc environment - 3.4.5 (mingw-vista special r3) Warning: '-L.' changed to '-LC:/src/chipcard_neu/opensc/Maplat-CCReade +r/.' Note (probably harmless): No library found for -lopensc MakeMaker (v6.56) Warning (non-fatal): Target 'dynamic' depends on targets in skipped se +ction 'dyn amic_lib' Warning (non-fatal): Target 'static' depends on targets in skipped sec +tion 'stat ic_lib' Writing Makefile for Maplat::CCReader::ccreadlib Writing Makefile for Maplat::CCReader C:\src\chipcard_neu\opensc\Maplat-CCReader>dir *.dll Volume in Laufwerk C: hat keine Bezeichnung. Volumeseriennummer: 8CF0-773E Verzeichnis von C:\src\chipcard_neu\opensc\Maplat-CCReader 15.07.2011 13:49 1.468.416 opensc.dll 1 Datei(en) 1.468.416 Bytes 0 Verzeichnis(se), 1.699.016.704 Bytes frei

        Then i run dmake -v for a while and then it breaks when making the CCReader.dll on this command:

        C:\Perl\site\bin\g++.exe -o blib\arch\auto\Maplat\CCReader\CCReader.dl +l -Wl,--ba se-file -Wl,dll.base -mdll -L"C:\Perl\lib\CORE" CCReader.o -Wl,--image +-base,0x22 270000 ccreadlib/libccreadlib.a C:\Perl\lib\CORE\perl512.lib C:\Perl\s +ite\lib\au to\MinGW\lib\libkernel32.a C:\Perl\site\lib\auto\MinGW\lib\libuser32.a + C:\Perl\s ite\lib\auto\MinGW\lib\libgdi32.a C:\Perl\site\lib\auto\MinGW\lib\libw +inspool.a C:\Perl\site\lib\auto\MinGW\lib\libcomdlg32.a C:\Perl\site\lib\auto\Mi +nGW\lib\li badvapi32.a C:\Perl\site\lib\auto\MinGW\lib\libshell32.a C:\Perl\site\ +lib\auto\M inGW\lib\libole32.a C:\Perl\site\lib\auto\MinGW\lib\liboleaut32.a C:\P +erl\site\l ib\auto\MinGW\lib\libnetapi32.a C:\Perl\site\lib\auto\MinGW\lib\libuui +d.a C:\Per l\site\lib\auto\MinGW\lib\libws2_32.a C:\Perl\site\lib\auto\MinGW\lib\ +libmpr.a C :\Perl\site\lib\auto\MinGW\lib\libwinmm.a C:\Perl\site\lib\auto\MinGW\ +lib\libver sion.a C:\Perl\site\lib\auto\MinGW\lib\libodbc32.a C:\Perl\site\lib\au +to\MinGW\l ib\libodbccp32.a C:\Perl\site\lib\auto\MinGW\lib\libcomctl32.a C:\Perl +\site\lib\ auto\MinGW\lib\libmsvcrt.a dll.exp

        It fails with a lot of "undefined reference" messages, all for functions in opensc.dll:
        ccreadlib/libccreadlib.a(ccreadlib.o):ccreadlib.c:(.text+0x2c): undefi +ned refere nce to `sc_card_ctl' ccreadlib/libccreadlib.a(ccreadlib.o):ccreadlib.c:(.text+0x144): undef +ined refer ence to `sc_release_context' ccreadlib/libccreadlib.a(ccreadlib.o):ccreadlib.c:(.text+0x157): undef +ined refer ence to `sc_unlock' ccreadlib/libccreadlib.a(ccreadlib.o):ccreadlib.c:(.text+0x164): undef +ined refer ence to `sc_disconnect_card' ...

        If i run this command manually and add -L. -lopensc, it works. Then i can continue the run of dmake to completion. The tests that use the DLL-functions run fine and everything.

        Don't use '#ff0000':
        use Acme::AutoColor; my $redcolor = RED();
        All colors subject to change without notice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://939471]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-09-16 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (157 votes), past polls