perlgcc


One of the more common complaints that you hear from people regarding perl on Solaris is that you need the Sun CC compiler to compile modules. This was addressed quite some time ago, but as I generally have cc available I never really notice the issue. Or I didn't until about ten minutes ago.

I need a local copy of Expect.pm for some stuff I'm working on, so I went off to compile up IO::Tty which is required by the Expect.pm module. And as I typed make I get the following.

/usr/bin/perl /usr/perl5/5.8.4/lib/ExtUtils/xsubpp  -typemap 
/usr/perl5/5.8.4/lib/ExtUtils/typemap  Tty.xs > Tty.xsc && mv Tty.xsc Tty.c
cc -c    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO -xO3 -xspace -xildoff    
-DVERSION=\\"1.02\\"  -DXS_VERSION=\\"1.02\\" -KPIC 
"-I/usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE"  -DHAVE_DEV_PTMX -DHAVE_GRANTPT 
-DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STRLCPY -DHAVE_SYS_STROPTS_H -DHAVE_TERMIOS_H 
-DHAVE_TERMIO_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT Tty.c
cc: unrecognized option `-KPIC'
cc: language ildoff not recognized
cc: Tty.c: linker input file unused because linking not done
Running Mkbootstrap for IO::Tty ()
chmod 644 Tty.bs
rm -f blib/arch/auto/IO/Tty/Tty.so
LD_RUN_PATH="" cc  -G Tty.o  -o blib/arch/auto/IO/Tty/Tty.so
cc: Tty.o: No such file or directory
cc: no input files
\*\*\* Error code 1
make: Fatal error: Command failed for target `blib/arch/auto/IO/Tty/Tty.so'
Basically whats happened here is that perl is compiled with the Sun compilers, and I'm trying to compile this module with gcc from /usr/sfw/bin. And perl doesn't like this (you can go take a look at /usr/perl5/5.8.4/lib/i86pc-solaris-64int/Config.pm for all the gory detail).

Anyway the work around is to use a handy little script bundled in Solaris called perlgcc, so rather than your normal perl Makefile.PL; make; make test; make install you do

/usr/perl5/5.8.4/bin/perlgcc Makefile.PL; make
and away you go. As an aside -KPIC is an option for generating position idependent code, and is dealt with in a lot more detail in the linkers and libraries documentation.
Comments:

Thanks a lot for the information. I have seen this error a few times and you're explanation and suggested work around were right on ther mark. This saved me a lot of time.

Posted by kingkongbundy on February 07, 2006 at 11:47 AM GMT #

Thanks for the tip. Haven't had to deal with this for a while either. Just moved into a new job and this sure did come in handy!

Posted by Daniel J. Doughty on November 08, 2007 at 12:37 PM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

fintanr

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today