Re: Calling External DLL functions in Perl using Inline



ben.sommer@xxxxxxx wrote:
> Sisyphus wrote:
> > <ben.sommer@xxxxxxx>
> > >
> > >
> > > Hi All.
> > >
> > > I'm just wondering how this problem resolved for you, Sankaran. I have
> > > the (almost) exact same problem, though my environment is cygwin+gcc.
> >
> > Brian McCauley suggested the specific problem to which you allude was the
> > result of trying to process C++ source code with the compiler in C mode. If
> > that's so (and I've seen a couple of other posts suggesting the same thing)
> > then I think the solution would be to either convert the C++ source to C, or
> > use Inline::CPP.
> >
> > With gcc, you need to be compiling C++ code with g++, not gcc - so if,
> > during the installation of Inline::CPP, you're prompted for which compiler
> > to use, make sure that g++ is specified.
> >
> > So ..... I guess the advice is for you to use Inline::CPP if the source is
> > C++. If the source is C and you're still getting those errors, then let us
> > know.
> >
> > > The user32.dll example from the Inline docs works flawlessly for me as
> > > well.
> >
> > That's C code, so one would expect no problem there.
> >
> > >Also, for my application, any conceivable permutation of the INC
> > > or LIBS directives (and windows/cygwin LIB/INC/PATH environment
> > > variables) always results in this:
> > >
> > > Note (probably harmless): No library found for '-lMyLib'
> > >
> >
> > Sometimes that warning actually *is* harmless - I see it from time to time,
> > but I only ever take notice of it whenever 'MyLib' is not found.
> >
> > If the lib is not being found, have you tried:
> > LIBS => '-L/full_path/to_MyLib -lMyLib',
>
> Oh yes. Like I said, I've tried every concveivable permutation.
>
> > If you specify '-lMyLib', will gcc find a file called 'MyLib.a', or will it
> > find only a file named 'libMyLib.a' ? (I think it will find either, but you
> > might check on that in case there's a problem there.)
> >
> > Let us know how you get on with this.
>
> A gracious response Rob. Many thanks.
>
> Well, you pointed out an inconsistency: my .lib and .dll files don't
> have .a extension. I gratuitously added one and the "No library found"
> error dissapeared. How annoying. I grokked the gcc man page and see
> what you mean about library file extensions (and prepensions). I'll
> send a note to the Inline::C author asking him to include a caveat in
> the section of his docs that talks about DLLs.
>
> Cygwin is sometimes confusing, kinda windows, kinda unix. Sometimes
> case sensitive, sometimes not.

Well, cygwin is the problem, though I might also fault the Inline::C
documentation. Taking that DLL example from the Inline::C cookbook...

http://search.cpan.org/~ingy/Inline-0.44/C/C-Cookbook.pod#Win32

use Inline C => DATA =>
LIBS => '-luser32';

$text = "@ARGV" || 'Inline.pm works with MSWin32. Scary...';

WinBox('Inline Text Box', $text);

__END__
__C__

#include <windows.h>

int WinBox(char* Caption, char* Text) {
return MessageBoxA(0, Text, Caption, 0);
}


That config directive "LIBS => '-luser32'" looks pretty key right? It
says 'go call "user32.dll", right? Wrong. It does nothing. Remove it
and the code compiles and runs the same. Its the windows.h include file
that makes this example - and probably all Win32 dlls - work under
cygwin, thanks to all the hand-rolled header files in
/usr/include/w32api. I'd love to hear from people using Inline::C under
cygwin with gcc and a _custom_ DLL file. How do you manage to link it.
How do are you able to include your own header files? Please prove me
wrong! I'd even listen to people having success with ActiveState perl
and Visual Studio (ugh). Off to post to the cygwin list...

Best,
--
Ben Sommer
Senior Technology Officer
Eastern Nazarene College
23 East Elm Ave
Quincy, MA 02170

.



Relevant Pages

  • Re: Calling External DLL functions in Perl using Inline
    ... > Taking that DLL example from the Inline::C cookbook... ... I think that script builds ok when you remove the LIBS directive because ... be different under Cygwin. ... > How do are you able to include your own header files? ...
    (comp.lang.perl.modules)
  • Re: Form feed character in header files
    ... so I've been replacing these (by copying into Wordpad ... Why are you messing about with compiler standard header files? ... Next time you upgrade Cygwin you may get new copies of the header ...
    (comp.lang.c)
  • Re: Form feed character in header files
    ... most of the header files for gcc and g++ used UNIX style ... so I've been replacing these (by copying into Wordpad ... You might have more luck in a Cygwin group. ... could even imagine Cygwin to behave differently from normal gcc. ...
    (comp.lang.c)
  • RE: Cygwin/DBD::ODBC issue
    ... cygwin header files rather than DBD::ODBC (hence the cross-post to the ... Its having some trouble compiling the header files. ... $ perl Makefile.PL ... this looks like a Microsoft ODBC type of driver manager. ...
    (perl.dbi.users)