frei

旧「anney's room」からブログ「frei」だけ引っ越し&残しました

perlcc。

perlでちょっと調べたい事があって、本筋からちょっとハズれるんだけど

perlccコンパイルしたメモ。

まずはサンプルで軽くperlスクリプトを書く。

#!/usr/bin/perl -w

use strict;

print "hello!\n";

exit;

それからコンパイル…のつもりが

anigon@colinux:~/compile$ perlcc test.pl

pccIauwd.c: In function `perl_init_aaaa':

pccIauwd.c:3280: warning: this decimal constant is unsigned only in ISO C90

/usr/bin/ld: cannot find -lperl

libperl がないと言っているらしい。

anigon@colinux:~/compile$ su

Password:

colinux:/home/anigon/compile# /sbin/ldconfig -p | grep perl

libperl.so.5.8 (libc6) => /usr/lib/libperl.so.5.8

なるほど、確かにないかもね。

colinux:/lib# cd /usr/lib

colinux:/usr/lib# ls -alt *perl*

lrwxrwxrwx 1 root root 16 Sep 9 00:08 libperl.so.5.8 -> libperl.so.5.8.4

-rw-r--r-- 1 root root 1150824 May 10 2006 libperl.so.5.8.4

やっぱりね。

colinux:/usr/lib# ln -s libperl.so.5.8 libperl.so

シンボリックリンク作って…

anigon@colinux:~/compile$ perlcc test.pl

pccL1NH7.c: In function `perl_init_aaaa':

pccL1NH7.c:3280: warning: this decimal constant is unsigned only in ISO C90

anigon@colinux:~/compile$

再度コンパイル

今度は通りましたね。

anigon@colinux:~/compile$ ls -alt

total 200

drwxr-xr-x 2 anigon anigon 4096 Feb 10 18:22 .

-rwxr-xr-x 1 anigon anigon 183501 Feb 10 18:22 a.out

-rw-r--r-- 1 anigon anigon 57 Feb 10 18:13 test.pl

-rw------- 1 anigon anigon 91 Feb 10 18:12 pccNNjDz

drwxr-xr-x 16 anigon anigon 4096 Feb 10 18:12 ..

お、a.out が出来てます、出来てます。

anigon@colinux:~/compile$ ./a.out

hello!

あ、よしよし。

anigon@colinux:~/compile$ time ./a.out

hello!

real 0m0.032s

user 0m0.010s

sys 0m0.020s

はぁ、そんなもんですか。

anigon@colinux:~/compile$ time perl test.pl

hello!

real 0m0.026s

user 0m0.030s

sys 0m0.000s

あらら。a.out のが遅いわね。

まぁ、この程度の軽いもんなら、コンパイルしてもあんまり効果ないか(笑)

perlfaq3

一般的にいって、コンパイラーはPerlプログラムを小さくもしませんし、早くもしなければ、移植性を増すこともせず、安全にもしません。実際、状況がより悪くなることもあります。

あら、そうなんですか。了解。