[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] When a DLL isn't a DLL.

From: David Mertens
Subject: Re: [Tinycc-devel] When a DLL isn't a DLL.
Date: Wed, 14 Aug 2013 17:18:56 -0400

Livespi -

A while ago I started work on a Perl wrapper for libtcc so that Perl can have just-in-time compilation of C code that compiles faster than Inline::C. Your question caused me to dust off the work, which was in something of a limbo state, and finish the mechanism for exposing C functions to Perl. I also updated the documentation while I was working on it. Active work is under one of my github repositories. As of this morning, you can now compile C functions in Perl at runtime, and invoke them from Perl! As of this afternoon, the documentation will actually tell you something useful. :-)

I realize that this doesn't address your exact problem, loading dlls. But if you are trying to dynamically load tcc-compiled dlls because you're building C code at runtime, this will give you a TCC-powered alternative. To get an idea for how it works, see the main module's documentation, as well as the documentation for TCC::Callable. This is actually in a good enough state that I should be able to upload it to CPAN, and I will do that once I've got it working for Windows. If could also get it working for Mac, that'd be awesome. :-)

Although I have developed this on Linux, it should be able to detect tcc and work on Windows. I'd be interested to hear feedback and to update the module with more features that you might find useful. I'd be happy to work on this to get it working for Windows if it doesn't work.


On Fri, Aug 9, 2013 at 2:30 PM, livespi <address@hidden> wrote:
Greetings all,
Does anyone here have cross-language knowledge/experience with Perl on
I can build dll's with tcc using the "-shared" flag, and they work fine
when I  call the dll functions FROM a tcc program.

Perl has a package Win32::API which allows you to call dll functions from
within  a Perl script.  It works fine when calling dll's that come from
Microsoft.   However, when I call my dll's built with tcc, Perl crashes.
>From research on the  web, this indicates an incompatible "calling
convention" i.e. stack arrangement  for function calls. I have to re-build
my dll's with mingw-gcc and dlltool  (which comes with StrawberryPerl)
before I can use them with Perl. This doesn't  make sense to me because
tcc can call MS dll's.

Are the dll's produced by tcc not the same as the dll's from Microsoft?  Is
this  a known issue?  If so, why have the -shared flag at all and just use
a .a or  .lib? I thought tcc was compatible with mingw gcc.

If anyone can shed some light on this I would be grateful.

                        *** WinXP using Popcorn email client

Tinycc-devel mailing list

 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]