swoop has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to prepare the makefile for IO::Tty to compile. Yet when I run the perl Makefile.PL I receive errors immediately:

SERVERx:IO-Tty-1.10$ /usr/local/bin/perl Makefile.PL `cat ../install`
Now let's see what we can find out about your system (logfiles of failing tests are available in the conf/ dir)...

ERROR: cannot run the configured compiler 'gcc'
(see conf/compilerok.log). Suggestions:
1) The complier 'gcc' is not in your PATH. Add it to the PATH and try again. OR
2) The compiler isn't installed on your system. Install it. OR
3) You only have a different compiler installed (e.g. 'gcc').
Either fix the compiler config in the perl Config.pm or install a perl that was built with the right compiler (you could build perl yourself with the available compiler).

Note: this is a system-administration issue, please ask your local admin for help. Thank you.

SERVERx:IO-Tty-1.10$ which gcc
/usr/local/bin/gcc

SERVERx:IO-Tty-1.10$ /usr/local/bin/gcc -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/3.1/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls Thread model: posix
gcc version 3.1

SERVERx:IO-Tty-1.10$ /usr/local/bin/perl -v

This is perl, v5.8.8 built for sun4-solaris

Copyright 1987-2006, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.

SERVERx:IO-Tty-1.10$

SERVERx:IO-Tty-1.10$ uname -a SunOS SERVERx 5.8 Generic_108528-23 sun4u sparc SUNW,UltraAX-i2



I tried the exact same sequence of commands on another older server running much older version of gcc and it works fine. Can someone let me know what I might be doing wrong?

Replies are listed 'Best First'.
Re: Compiling perl module
by ikegami (Patriarch) on Jan 20, 2011 at 22:46 UTC

    Let's assume it can find gcc, since that seems very likely. Based on the snippet posted by Anonyrmous (++), there are a couple of other obvious causes. Something in $flags could be unsupported, or maybe the gcc install is broken. In both cases, something useful should be in compilerok.log.

    The simplest solution might be to install your own Perl rather than trying to address incompatibilities between your gcc and the one used to build your perl. App::perlbrew is a convenient way of locally installing a version of Perl.

Re: Compiling perl module
by Anonyrnous Monk (Hermit) on Jan 20, 2011 at 22:21 UTC

    The respective test that leads to the error message is

    chdir('conf') or die "chdir: $!"; open(TST,">compilerok.c") or die "open: $!"; print TST <<'ESQ'; int main () { return 0; } ESQ close(TST); if (system("$Config{'cc'} $flags compilerok.c > compilerok.log 2>&1")) + { die <<"__EOT__"; ...

    so looking into compilerok.log (as it says in the message) might give a clue as to why that simple snippet of C code cannot be compiled.

Re: Compiling perl module
by swoop (Acolyte) on Jan 20, 2011 at 22:50 UTC
    Here is the contents of the files output in the conf directory. Not much help:

    SERVERx:IO-Tty-1.10$ cat conf/compilerok.c
    int main () { return 0; }

    SERVERx:IO-Tty-1.10$ cat conf/compilerok.log
    cc1: unrecognized option `-Wdeclaration-after-statement'
    cc1: warning: changing search order for system directory "/usr/local/include"
    cc1: warning: as it has already been specified as a non-system directory

      Your perl was built with a gcc that understands -Wdeclaration-after-statement. Yours doesn't. The following are the solution in increasing order or reliability:

      • Hack it so it works (perhaps using ExtUtils::FakeConfig).
      • Switch to a compatible compiler (perhaps by upgrading your gcc).
      • Build a perl for your own use (perhaps using App::perlbrew, although it's easy to do from scratch too).