Compiling a full C library using Perl tools

ExtUtils::CBuilder supports C code compilation mechanisms whenever a C compiler is available. That is true on most Mac OS X installations and other UNIX flavors like Linuxes. Unfortunately that is not so common for Windows, but Strawberry Perl includes a GCC-based C compiler and a standard libc library.

This means that if a C compiler is available it should be possible to compile a C program, and to compile a C library. And that is true. Unfortunately ExtUtils::CBuilder includes method to compile bundle libraries and not common dynamic libraries. If you do not know what that means, probably you are using a common Linux. For Mac OS X we have that difference: the libraries created by standard Perl modules are bundles and not full featured libraries.

So, I needed a method to compile a standard C library on, at least, these three operating systems (Mac OS X, UNIX and Strawberry Perl). I found a solution for that performing experiments on these operating systems. The code is not clean. The code is subject to fail. But the code is working and made it possible to release Text::BibTeX.

Now, where this code, for compiling C libraries, is included? At the moment it is included and hidden under a module in Config::AutoConf::Linker. It is not the correct place (I would prefer it to be present on ExtUtils::CBuilder) but I will not submit a patch to CBuilder while my code is not stable.

As my experience on this subject is not big (I just managed to get the code to work performing successive experiments), I leave here the request for help and patches for anybody with more in depth knowledge on this subject.

1 Comment

I've been thinking about doing just that, but last time I looked ExtUtils::CBuilder couldn't do what I needed. It's a bit more capable now, though I'm running into bugs and limitations quite quickly. Nonetheless an interesting possibility.

Leave a comment

About Alberto Simões

user-pic I blog about Perl. D'uh!