Dr. Mu has asked for the wisdom of the Perl Monks concerning the following question:

I've recently installed Inline::C on Gutsy Gibbon (Ubuntu 7.10) and have written a test program:
use strict; use Inline ( C => 'DATA' ); print add(3, 5); 1; __DATA__ __C__ int add(int x, int y) { return x + y; }
When run, it gives me the following output in STDERR:

/usr/bin/perl /usr/share/perl/5.8/ExtUtils/xsubpp -typemap /usr/share +/perl/5.8/ExtUtils/typemap inline_C_test_pl_6d69.xs > inline_C_test +_pl_6d69.xsc && mv inline_C_test_pl_6d69.xsc inline_C_test_pl_6d69.c cc -c -I/home/phil/jobs/perl -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAV +E_PIDS -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LA +RGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"0.00\" -DXS_V +ERSION=\"0.00\" -fPIC "-I/usr/lib/perl/5.8/CORE" inline_C_test_pl_6 +d69.c In file included from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perl.h:420:24: error: sys/types.h: No such file + or directory /usr/lib/perl/5.8/CORE/perl.h:451:19: error: ctype.h: No such file or +directory /usr/lib/perl/5.8/CORE/perl.h:463:23: error: locale.h: No such file or + directory /usr/lib/perl/5.8/CORE/perl.h:480:20: error: setjmp.h: No such file or + directory /usr/lib/perl/5.8/CORE/perl.h:486:26: error: sys/param.h: No such file + or directory /usr/lib/perl/5.8/CORE/perl.h:491:23: error: stdlib.h: No such file or + directory /usr/lib/perl/5.8/CORE/perl.h:496:23: error: unistd.h: No such file or + directory /usr/lib/perl/5.8/CORE/perl.h:776:23: error: string.h: No such file or + directory /usr/lib/perl/5.8/CORE/perl.h:925:27: error: netinet/in.h: No such fil +e or directory /usr/lib/perl/5.8/CORE/perl.h:929:26: error: arpa/inet.h: No such file + or directory /usr/lib/perl/5.8/CORE/perl.h:939:25: error: sys/stat.h: No such file +or directory /usr/lib/perl/5.8/CORE/perl.h:961:21: error: time.h: No such file or d +irectory /usr/lib/perl/5.8/CORE/perl.h:968:25: error: sys/time.h: No such file +or directory /usr/lib/perl/5.8/CORE/perl.h:975:27: error: sys/times.h: No such file + or directory /usr/lib/perl/5.8/CORE/perl.h:982:19: error: errno.h: No such file or +directory /usr/lib/perl/5.8/CORE/perl.h:997:25: error: sys/socket.h: No such fil +e or directory /usr/lib/perl/5.8/CORE/perl.h:1024:21: error: netdb.h: No such file or + directory /usr/lib/perl/5.8/CORE/perl.h:1127:24: error: sys/ioctl.h: No such fil +e or directory /usr/lib/perl/5.8/CORE/perl.h:1156:23: error: dirent.h: No such file o +r directory In file included from /usr/lib/gcc/i486-linux-gnu/4.1.3/include/syslim +its.h:7, from /usr/lib/gcc/i486-linux-gnu/4.1.3/include/limits +.h:11, from /usr/lib/perl/5.8/CORE/perl.h:1510, from inline_C_test_pl_6d69.xs:2: /usr/lib/gcc/i486-linux-gnu/4.1.3/include/limits.h:122:61: error: limi +ts.h: No such file or directory In file included from /usr/lib/perl/5.8/CORE/perl.h:2120, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/handy.h:136:25: error: inttypes.h: No such file + or directory In file included from /usr/lib/perl/5.8/CORE/perl.h:2284, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/unixish.h:106:21: error: signal.h: No such file + or directory In file included from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perl.h:2421:33: error: pthread.h: No such file +or directory In file included from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perl.h:2423: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘perl_os_thread’ /usr/lib/perl/5.8/CORE/perl.h:2424: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘perl_mutex’ /usr/lib/perl/5.8/CORE/perl.h:2425: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘perl_cond’ /usr/lib/perl/5.8/CORE/perl.h:2426: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘perl_key’ In file included from /usr/lib/perl/5.8/CORE/iperlsys.h:51, from /usr/lib/perl/5.8/CORE/perl.h:2733, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perlio.h:65:19: error: stdio.h: No such file or + directory In file included from /usr/lib/perl/5.8/CORE/iperlsys.h:51, from /usr/lib/perl/5.8/CORE/perl.h:2733, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perlio.h:259: error: expected ‘)’ b +efore ‘*’ token /usr/lib/perl/5.8/CORE/perlio.h:262: error: expected ‘=’, +‘,’, ‘;’, ‘asm’ or ‘__attri +bute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/perlio.h:265: error: expected ‘=’, +‘,’, ‘;’, ‘asm’ or ‘__attri +bute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/perlio.h:268: error: expected declaration speci +fiers or ‘...’ before ‘FILE’ In file included from /usr/lib/perl/5.8/CORE/perl.h:2747, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/sv.h:389: error: expected specifier-qualifier-l +ist before ‘DIR’ In file included from /usr/lib/perl/5.8/CORE/op.h:497, from /usr/lib/perl/5.8/CORE/perl.h:2754, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/reentr.h:72:20: error: pwd.h: No such file or d +irectory /usr/lib/perl/5.8/CORE/reentr.h:75:20: error: grp.h: No such file or d +irectory /usr/lib/perl/5.8/CORE/reentr.h:85:26: error: crypt.h: No such file or + directory /usr/lib/perl/5.8/CORE/reentr.h:90:27: error: shadow.h: No such file o +r directory In file included from /usr/lib/perl/5.8/CORE/op.h:497, from /usr/lib/perl/5.8/CORE/perl.h:2754, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/reentr.h:612: error: field ‘_crypt_struct +’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:620: error: field ‘_drand48_stru +ct’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:624: error: field ‘_grent_struct +’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:635: error: field ‘_hostent_stru +ct’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:654: error: field ‘_netent_struc +t’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:669: error: field ‘_protoent_str +uct’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:684: error: field ‘_pwent_struct +’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:695: error: field ‘_servent_stru +ct’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:710: error: field ‘_spent_struct +’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:721: error: field ‘_gmtime_struc +t’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:724: error: field ‘_localtime_st +ruct’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:771: error: field ‘_random_struc +t’ has incomplete type /usr/lib/perl/5.8/CORE/reentr.h:772: error: expected specifier-qualifi +er-list before ‘int32_t’ In file included from /usr/lib/perl/5.8/CORE/perl.h:2756, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/av.h:13: error: expected specifier-qualifier-li +st before ‘ssize_t’ In file included from /usr/lib/perl/5.8/CORE/perl.h:2759, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/scope.h:232: error: expected specifier-qualifie +r-list before ‘sigjmp_buf’ In file included from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perl.h:2931: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘getuid’ /usr/lib/perl/5.8/CORE/perl.h:2932: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘geteuid’ /usr/lib/perl/5.8/CORE/perl.h:2933: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘getgid’ /usr/lib/perl/5.8/CORE/perl.h:2934: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘getegid’ In file included from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perl.h:3238:22: error: math.h: No such file or +directory In file included from /usr/lib/perl/5.8/CORE/perl.h:3881, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/thrdvar.h:85: error: field ‘Tstatbuf&#821 +7; has incomplete type /usr/lib/perl/5.8/CORE/thrdvar.h:86: error: field ‘Tstatcache&#8 +217; has incomplete type /usr/lib/perl/5.8/CORE/thrdvar.h:91: error: field ‘Ttimesbuf&#82 +17; has incomplete type In file included from /usr/lib/perl/5.8/CORE/perl.h:3883, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/intrpvar.h:66: error: expected specifier-qualif +ier-list before ‘time_t’ In file included from /usr/lib/perl/5.8/CORE/perl.h:3950, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/proto.h:128: error: expected declaration specif +iers or ‘...’ before ‘mode_t’ /usr/lib/perl/5.8/CORE/proto.h:128: error: expected declaration specif +iers or ‘...’ before ‘uid_t’ /usr/lib/perl/5.8/CORE/proto.h:297: error: expected declaration specif +iers or ‘...’ before ‘off64_t’ /usr/lib/perl/5.8/CORE/proto.h:299: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘Perl_do_sysseek’ /usr/lib/perl/5.8/CORE/proto.h:300: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘Perl_do_tell’ /usr/lib/perl/5.8/CORE/proto.h:411: error: expected declaration specif +iers or ‘...’ before ‘gid_t’ /usr/lib/perl/5.8/CORE/proto.h:411: error: expected declaration specif +iers or ‘...’ before ‘uid_t’ /usr/lib/perl/5.8/CORE/proto.h:736: error: expected ‘=’, & +#8216;,’, ‘;’, ‘asm’ or ‘__attrib +ute__’ before ‘Perl_my_fork’ /usr/lib/perl/5.8/CORE/proto.h:1020: error: expected declaration speci +fiers or ‘...’ before ‘pid_t’ /usr/lib/perl/5.8/CORE/proto.h:1300: error: expected declaration speci +fiers or ‘...’ before ‘pid_t’ /usr/lib/perl/5.8/CORE/proto.h:1456: error: expected ‘=’, +‘,’, ‘;’, ‘asm’ or ‘__attri +bute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/proto.h:2001: error: expected ‘=’, +‘,’, ‘;’, ‘asm’ or ‘__attri +bute__’ before ‘Perl_PerlIO_read’ /usr/lib/perl/5.8/CORE/proto.h:2002: error: expected ‘=’, +‘,’, ‘;’, ‘asm’ or ‘__attri +bute__’ before ‘Perl_PerlIO_write’ /usr/lib/perl/5.8/CORE/proto.h:2003: error: expected ‘=’, +‘,’, ‘;’, ‘asm’ or ‘__attri +bute__’ before ‘Perl_PerlIO_unread’ /usr/lib/perl/5.8/CORE/proto.h:2004: error: expected ‘=’, +‘,’, ‘;’, ‘asm’ or ‘__attri +bute__’ before ‘Perl_PerlIO_tell’ /usr/lib/perl/5.8/CORE/proto.h:2005: error: expected declaration speci +fiers or ‘...’ before ‘off64_t’ In file included from /usr/lib/perl/5.8/CORE/perl.h:3988, from inline_C_test_pl_6d69.xs:2: /usr/lib/perl/5.8/CORE/perlvars.h:31: error: expected ‘=’, + ‘,’, ‘;’, ‘asm’ or ‘__attr +ibute__’ before ‘PL_thr_key’ /usr/lib/perl/5.8/CORE/perlvars.h:48: error: expected ‘=’, + ‘,’, ‘;’, ‘asm’ or ‘__attr +ibute__’ before ‘PL_op_mutex’ /usr/lib/perl/5.8/CORE/perlvars.h:52: error: expected ‘=’, + ‘,’, ‘;’, ‘asm’ or ‘__attr +ibute__’ before ‘PL_dollarzero_mutex’ /usr/lib/perl/5.8/CORE/perl.h:4485:24: error: sys/ipc.h: No such file +or directory /usr/lib/perl/5.8/CORE/perl.h:4486:24: error: sys/sem.h: No such file +or directory /usr/lib/perl/5.8/CORE/perl.h:4611:24: error: sys/file.h: No such file + or directory In file included from /usr/lib/perl/5.8/CORE/perlapi.h:38, from /usr/lib/perl/5.8/CORE/XSUB.h:349, from inline_C_test_pl_6d69.xs:3: /usr/lib/perl/5.8/CORE/intrpvar.h:66: error: expected ‘=’, + ‘,’, ‘;’, ‘asm’ or ‘__attr +ibute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/intrpvar.h:237: error: expected ‘=’ +, ‘,’, ‘;’, ‘asm’ or ‘__att +ribute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/intrpvar.h:238: error: expected ‘=’ +, ‘,’, ‘;’, ‘asm’ or ‘__att +ribute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/intrpvar.h:239: error: expected ‘=’ +, ‘,’, ‘;’, ‘asm’ or ‘__att +ribute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/intrpvar.h:240: error: expected ‘=’ +, ‘,’, ‘;’, ‘asm’ or ‘__att +ribute__’ before ‘*’ token In file included from /usr/lib/perl/5.8/CORE/perlapi.h:39, from /usr/lib/perl/5.8/CORE/XSUB.h:349, from inline_C_test_pl_6d69.xs:3: /usr/lib/perl/5.8/CORE/perlvars.h:31: error: expected ‘=’, + ‘,’, ‘;’, ‘asm’ or ‘__attr +ibute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/perlvars.h:48: error: expected ‘=’, + ‘,’, ‘;’, ‘asm’ or ‘__attr +ibute__’ before ‘*’ token /usr/lib/perl/5.8/CORE/perlvars.h:52: error: expected ‘=’, + ‘,’, ‘;’, ‘asm’ or ‘__attr +ibute__’ before ‘*’ token inline_C_test_pl_6d69.c: In function ‘XS_main_add’: inline_C_test_pl_6d69.c:23: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:23: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:23: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:25: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:27: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:27: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:27: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:27: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:28: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:28: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:28: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:28: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:30: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:30: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:30: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:30: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:33: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:33: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:33: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:35: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:35: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c: In function ‘boot_inline_C_test_pl_6d69 +’: inline_C_test_pl_6d69.c:44: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:44: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:44: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:47: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:49: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:50: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:50: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:50: error: invalid type argument of ‘una +ry *’ inline_C_test_pl_6d69.c:50: error: invalid type argument of ‘una +ry *’ make: *** [inline_C_test_pl_6d69.o] Error 1 A problem was encountered while attempting to compile and install your + Inline C code. The command that failed was: make > out.make 2>&1 The build directory was: /home/phil/jobs/perl/_Inline/build/inline_C_test_pl_6d69 To debug the problem, cd to the build directory, and inspect the outpu +t files. at inline_C_test.pl line 0 INIT failed--call queue aborted.

(Sorry about the UTF-8 characters. They don't display properly in Konqueror.) Anyway, what do I need to do to get this working? Thanks.

Replies are listed 'Best First'.
Re: Problems with Inline::C on Ubuntu
by tachyon-II (Chaplain) on Apr 22, 2008 at 06:56 UTC

    Looks like you need to install the C header files.

    Try

    sudo apt-get install linux-headers-`uname -r` build-essential

    Before you go messing with Inline::C I suggest you make sure you can compile a basic C program off the command line. Can you compile hello world?

      Begs the question of how he was able to install Inline::C to begin with
      tachyon-II:

      Thanks! Installing the headers worked like a champ! Kilobytes of error messages have been reduced to a single digit: 8.

      "Before you go messing with Inline::C I suggest you make sure you can compile a basic C program off the command line. Can you compile hello world?"

      Well, no. But I'm not interested in doing anything particularly complicated — just speeding up some Perl bit-twiddling subroutines. As you suspect, this C stuff is pretty much rote imitation for me at this point. But, with this obstacle removed, I'm confident I can slog through it.

      Thanks again for your help!

      -Phil

        Glad it worked. The suggestion to try a command line compile was simply to make sure you had a working setup - you do so all is well. You will find an extensive C tutorial here

        As anonymous monk asks above, how did you actually install Inline::C? As a binary package? Anyway now you have C working the usual methods described in A Guide to Installing Modules should work for just about everything.

        As you note your C compiler will often spew a scary long list of errors. It pays to concentrate on fixing just the first error (or chunk or errors) as once the compiler chokes most of the rest of the output is more or less meaningless. As soon as you fix the initial problem things will either work or you will have a whole new long list of errors!