Compiling Libraries

Some of my main modules (modules with more users) bundle C libraries within them: Lingua::Jspell and Text::BibTeX. One of the main problems of doing this is how to detect the C compiler, and how to use it. For example, for windows, I can only support (for now) Strawberry Perl (although I consider that great enough).

At the moment I am using Config::AutoConf to detect libraries and headers. Probably I would use ExtUtils::PkgConfig for libraries that know what that is. But that is not enough. I need to know how to link a standalone library, and that information is not available on any module (that I know). For example, ExtUtils::CBuilder has linking options, but they are tailored for "bundles", some kind of libraries that are not to be used from C, but from Perl, as a module. I am not very aware of the difference, but I know that under Linux they are mostly the same, for Mac OS X they will be called .bundle and not .dylib as a standard C library, and that under Windows the dll file produced is also different.

So, how I am linking those libraries on my modules? Well, I am using a submodule I added to Config::AutoConf (::Linker). It is a big hack. In fact, to call it a big hack is a pleonasm. It works for some (mostly cases), and I do not have any idea what it does in the remaining cases.

I am wondering if it is relevant to promote this code (with some cleanup, support for other compilers under windows -- if anyone is willing to help) to an ExtUtils::CBuilder::LibLinker (or any other name).

1 Comment

I would be interested in helping with, whatever tuits I can spare. I ran into trouble like this in Collision::2D. Having code in the headers ... is horrible.

Leave a comment

About Alberto Simões

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