Dan
Dan

Reputation: 63390

CPAN fails to compile C, how can I configure CCFLAGS?

I have a new FreeBSD 9.0 installation that is having trouble installing modules that require C via CPAN. It seems to be down to cc being called without -I/usr/local/include. I've tried overriding that by starting CPAN with INC="-I/usr/local/include" - while that fixes the problem for some modules, it breaks for others as it seems to be overriding any defaults set in makefiles.

I've got another box with pretty much the same setup on it (slightly older installation, but still FreeBSD 9.0), perl -V on the old box shows that ccflags contains -I/usr/local/include, whereas it doesn't on the new box.

I'm guessing this is why CPAN is calling cc without it.

Question is, how can I configure it?

Upvotes: 1

Views: 1300

Answers (2)

ikegami
ikegami

Reputation: 385506

If it works, your best bet is probably to add it to the ccflags entry in the file returned by

perl -E'require "Config_heavy.pl"; say $INC{"Config_heavy.pl"};'

Otherwise, there is surely a means of specifying this to ExtUtis::MakeMaker and to Module::Build installers. If so, you can set this cpan using o conf makepl_arg and o conf mbuildpl_arg. (Don't forget to commit!)

Upvotes: 1

Jonathan Leffler
Jonathan Leffler

Reputation: 753455

The settings used by CPAN modules come from the Config module which is part of core Perl. It records the compilation options and settings used when Perl was compiled.

For whatever reason, the person compiling Perl on your new FreeBSD 9.0 installation decided not to include -I/usr/local/include.

Fighting the settings in the Config module is hard work, as you've already discovered. On the whole, it is simplest not to fight it. If you want Perl to use /usr/local/include, then compile Perl so as to do so. You'll probably want to specify -l/usr/local/lib too.

You should check whether the versions of Perl are the same or not on your two similar systems.

Upvotes: 3

Related Questions