标签归档:编译

[原] 减小nginx编译后的文件大小 (Reduce file size of nginx)

默认的nginx编译选项里居然是用debug模式(-g)的(debug模式会插入很多跟踪和ASSERT之类),编译以后一个nginx有好几兆。
去掉nginx的debug模式编译,编译以后只有375K(nginx-0.5.33, gcc4)。
在 auto/cc/gcc,最后几行有:
# debug
CFLAGS=”$CFLAGS -g”
注释掉或删掉这几行,重新编译即可。-g参数用法详见这篇blog:[原]Linux下的c/c++ GDB调试

Nginx uses debug mode (-g) in compiling by default, which result in several MB of it’s size.
After debug disabled, the file size of nginx reduced to 375K (nginx-0.5.33, gcc4).
open auto/cc/gcc, find this at last several lines:
# debug
CFLAGS=”$CFLAGS -g”
delete it, and recompile. More of -g: Linux c/c++ GDB debug

[原] slackware 12.0 编译内核

make menuconfig 遇到错误:

In file included from scripts/lxdialog/checklist.c:24:
scripts/lxdialog/dialog.h:32:20: curses.h: No such file or directory
In file included from scripts/lxdialog/checklist.c:24:
scripts/lxdialog/dialog.h:130: error: syntax error before “use_colors”
scripts/lxdialog/dialog.h:130: warning: type defaults to int' in declaration of use_colors’
scripts/lxdialog/dialog.h:130: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:131: error: syntax error before “use_shadow”
scripts/lxdialog/dialog.h:131: warning: type defaults to int' in declaration of use_shadow’
scripts/lxdialog/dialog.h:131: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:133: error: syntax error before “attributes”
scripts/lxdialog/dialog.h:133: warning: type defaults to int' in declaration of attributes’
scripts/lxdialog/dialog.h:133: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:146: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:146: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:149: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:149: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:150: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:150: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:151: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:152: warning: function declaration isn’t a prototype
scripts/lxdialog/dialog.h:153: error: syntax error before ‘*’ token
scripts/lxdialog/dialog.h:153: warning: function declaration isn’t a prototype
scripts/lxdialog/checklist.c:32: error: syntax error before ‘*’ token
scripts/lxdialog/checklist.c:34: warning: function declaration isn’t a prototype
scripts/lxdialog/checklist.c: In function print_item':
scripts/lxdialog/checklist.c:38: warning: implicit declaration of function
wattrset’
scripts/lxdialog/checklist.c:38: error: win' undeclared (first use in this function)
scripts/lxdialog/checklist.c:38: error: (Each undeclared identifier is reported only once
scripts/lxdialog/checklist.c:38: error: for each function it appears in.)
scripts/lxdialog/checklist.c:39: warning: implicit declaration of function
wmove’
scripts/lxdialog/checklist.c:39: error: choice' undeclared (first use in this function)
scripts/lxdialog/checklist.c:41: warning: implicit declaration of function
waddch’
……

解决:
安装的时候少了一个包, 找到光盘里的 /slackware/l/ncruses-5.6-i486-2.tgz
# installpkg ncruses-5.6-i486-2.tgz
即可

[原]第一次完整地编译了Linux内核

啊,太痛苦了,从下午一直编译到凌晨,终于每个选项都搞清楚了是干嘛的。用的是最新的2.6.22.6内核。
slackware 12.0太好玩了,装好后有几个cpu就会在屏幕上方显示几个LOGO企鹅。一排八个真壮观。。。。

推荐这个文章: http://lamp.linux.gov.cn/Linux/kernel_options.html

共计遇到的主要问题如下:
1)LILO 不能装到MBR,好像做了raid的都不能写MBR。手动写lilo.conf可以解决。(从安装盘引导,mount /dev/cciss/盘 /d1,chroot /d1,然后就可以改 /etc/lilo.conf了,改完直接lilo)
2)make menuconfig报错。类似:
scripts/lxdialog/dialog.h:127: syntax error before “use_colors”
scripts/lxdialog/dialog.h:127: warning: type defaults to int' in declaration of use_colors’
scripts/lxdialog/dialog.h:127: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:128: syntax error before “use_shadow”
scripts/lxdialog/dialog.h:128: warning: type defaults to int' in declaration of use_shadow’
scripts/lxdialog/dialog.h:128: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:130: syntax error before “attributes”
原因是setup装系统的时候有make menuconfig要用到的开发语言和库没有安装进去。重新安装就可以了。网上其他发行版说的需要手动安装libncurses-dev,在Slackware 12.0并不需要,系统应该自带了。

3)网络不通。检查是驱动选错了。(lspci得到的结果不能全相信,仅供参考!我最后是从安装盘里的默认系统开机自检画面里面发现真实网卡驱动的)
4)VFS: cannot open root device。
可能的原因:A)尽管硬盘全都是SCSI,常规IDE里”INCLUDE IDE/ATA disk Support”这个还是得选上。否则就打不开根设备。。。- -!
B)Enable the block layer(块设备支持,使用硬盘/USB/SCSI设备者必选)-》Support for Large Block Devices(仅在使用大于2TB的块设备时需要)。这个选项我发现必须选上。尽管我只有8*140G,不到2T。但是实际上如果这个选项没有选的话可能起不来。因此我觉得这里是翻译有问题。原文并没有指明是2T。
可能还有其他选项上的问题,可以看看这个网址:http://kerneltrap.org/node/970

期间得到ever的大力帮助,特别感谢。
今天还是嘘嘘生日,真是对不住哦。。。。

[原]nginx在Slackware 11.0下的编译安装

configure就不说了,make的时候提示:
objs/src/event/ngx_event.o(.text+0xdbc): In function ngx_event_init_conf':src/event/ngx_event.c:1140: warning: warning: epoll_create is not implemented and will always fail
objs/src/event/modules/ngx_epoll_module.o(.text+0x1cc): In function
ngx_epoll_add_event’:src/event/modules/ngx_epoll_module.c:250: warning: warning: epoll_ctl is not implemented and will always fail
objs/src/event/modules/ngx_epoll_module.o(.text+0x416): In function `ngx_epoll_process_events’:src/event/modules/ngx_epoll_module.c:402: warning: warning: epoll_wait is not implemented and will always fail

epoll是高性能网络io,居然不被系统支持,我明明用的是2.6.17的内核。于是make menuconfig,到 General setup / Configure standard kernel features 发现’Enable event poll’ 是关闭的,于是启用。

然后重新编译内核:

话说,Slackware 12.0都出来几个月了,改天我要去装一下。^_^