|
Posted by ben.sommer on July 28, 2005, 8:14 am
Please log in for more thread options
Sisyphus wrote:
>
> > 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.
>
> No - I think that LIBS directive is saying "link to libuser32.a" - which you
> should find in Cygwin's gcc/lib folder.
> I think that script builds ok when you remove the LIBS directive because
> libuser32.a is linked to automatically. That automatic linking is built in
> by the ExtUtils modules. To verify, insert the following at the top of the
> script:
>
> use Inline C => Config =>
> BUILD_NOISY => 1;
>
> Then make some change to the C code in that script (to force it to rebuild -
> add or delete some white space is sufficient).
>
> Then re-run the script. Somewhere in the output you should see 'libuser32.a'
> mentioned (along with a heap of other libs).
>
> > 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.
>
> You'll possibly find you don't even have to specifically include windows.h
> either. Your Inline::C code will automatically include 'perl.h' and that
> might lead to the inclusion of 'windows.h'. On my perls that's the way it
> is, anyway. 'perl.h' includes 'win32.h' which includes 'windows.h'. It might
> be different under Cygwin.
>
> > 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.
>
> To link directly to a dll (which is possible with gcc, but not with
> Microsoft compilers) you specify the 'MYEXTLIB' config directive - eg:
>
> MYEXTLIB => "/full_path/to_dll/MyDLL.dll",
>
> > How do are you able to include your own header files?
>
> You just list them as you would in normal C code. You can use the 'INC'
> config directive to specify the directory that they are in (if they're not
> already in some standard location):
>
> INC => "-I/full_path/to_folder/that_contains/my_includes",
>
> > Please prove me
> > wrong! I'd even listen to people having success with ActiveState perl
> > and Visual Studio (ugh).
>
> I use gcc (MinGW) most of the time - but that's using 'gcc' in a native
> Win32 environment - not in a Cygwin environment. I also use MSVC++ 7.0
> (.NET) which is a very good compiler - though, for me, a little cumbersome
> to use. I prefer to use MinGW as I find I'm a lot more comfortable with it.
> I would never use Cygwin - for various reasons (most of which don't apply to
> everybody .... or do I mean "anybody" ? :-).
>
> >Off to post to the cygwin list...
> >
>
> For Inline::C questions, the best forum is the Inline mailing list. (See
> http://lists.perl.org/index.cgi :-)
>
> Cheers,
> Rob
Thanks so much, Rob. I'll be dilligent in trying all your suggestions.
Best,
~Ben Sommer
|