If you have strawberryperl, this works
C:\perlmonks747643>ls -lh total 12K -rw-rw-rw- 1 666 0 126 2009-03-03 01:31 myTest.cpp -rw-rw-rw- 1 666 0 49 2009-03-03 01:30 myTest.h -rw-rw-rw- 1 666 0 248 2009-03-03 01:35 myTest.pl C:\perlmonks747643>cat myTest.h extern "C" __declspec(dllexport) int test(int); C:\perlmonks747643>cat myTest.cpp #include "myTest.h" extern "C" __declspec(dllexport) int __stdcall test(int x) { x *= 2; return x; } C:\perlmonks747643>cat myTest.pl #!/usr/bin/perl -- use strict; use warnings; use Win32::API; use Win32::API::Callback; use Win32::API::Test; my $fun = Win32::API->new('myTest.dll', 'int test(int a)') or die $^E; my $Result = $fun->Call(12); print "12 * 2 = $Result\n"; C:\perlmonks747643>gcc -shared -o myTest.dll myTest.cpp -Wl,--add-stdc +all-alias C:\perlmonks747643>ls -lh total 28K -rw-rw-rw- 1 666 0 126 2009-03-03 01:31 myTest.cpp -rw-rw-rw- 1 666 0 13K 2009-03-03 01:36 myTest.dll -rw-rw-rw- 1 666 0 49 2009-03-03 01:30 myTest.h -rw-rw-rw- 1 666 0 248 2009-03-03 01:35 myTest.pl C:\perlmonks747643>perl myTest.pl 12 * 2 = 24 C:\perlmonks747643>pexports -v myTest.dll ; .text: RVA: 00001000, File offset: 00000400 ; .data: RVA: 00002000, File offset: 00000c00 ; .rdata: RVA: 00003000, File offset: 00000e00 ; .bss: RVA: 00004000, File offset: 00000000 ; .edata: RVA: 00005000, File offset: 00001000 ; Reading exports from section: .edata ; Export table: myTest.dll ; Ordinal base: 1 ; Ordinal table RVA: 00005038 ; Name table RVA: 00005030 ; Export address table RVA: 00005028 LIBRARY myTest.dll EXPORTS test ; .text ; RVA 00001180 test@4 ; .text ; RVA 00001180 ; .idata: RVA: 00006000, File offset: 00001200 ; .reloc: RVA: 00007000, File offset: 00001400 C:\perlmonks747643>

In reply to Re: need help while calling C++ Dll from Perl using Win32Api by Anonymous Monk
in thread need help while calling C++ Dll from Perl using Win32Api by anupama

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.