原作:见
原作写得比较简单,实际操作还是有很多问题,里面加了一些自已的心得(#部分)!
mldonkey是用OCmal语言写的,需要用OCmal编译器编译。由于无法交叉编译OCaml本身,所以只有在普通Linux机器上运行的MIPS虚拟机进行Ocaml和mldonkey的编译。
1. MIPS虚拟机安装
使用QEMU来虚拟MIPS系统,请在http://www.qemu.org/下载虚拟机的代码,编译安装:
./configure --prefix=/opt/qemu
make && make
# 我是在VM中的Ununtu中手工编译qemu的过程出错,无法make install。只好用Ununtu的软件包管理安装了Qemu.
#试过使用qemu manager6.0无法启动mips-qemu ,原因未明,如果xp下能行,编译会更简单些!
:
sudo apt-get install qemu-kvm-extras #安装qemu 0.11.0
[sudo] password for ccb:
正在读取软件包列表... 完成
正在xxxx包的依赖关系树
正在读取状态信息... 完成
下列【新】软件包将被安装:
qemu-kvm-extras
共升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 238 个软件未被升级。
需要下载 14.0MB 的软件包。
解压缩后会消耗掉 41.1MB 的额外空间。
获取:1 karmic-updates/main qemu-kvm-extras 0.11.0-0ubuntu6.3 [14.0MB]
下载 14.0MB,耗时 4 分钟 56 秒 (47.1kB/s)
选中了曾被取消选择的软件包 qemu-kvm-extras。
(正在读取数据库 ... 系统当前总共安装有 116955 个文件和目录。)
正在解压缩 qemu-kvm-extras (从 .../qemu-kvm-extras_0.11.0-0ubuntu6.3_i386.deb) ...
正在设置 qemu-kvm-extras (0.11.0-0ubuntu6.3) ...
在下载,某大牛为我们事先做好的Debain的操作系统,这样就不用在虚拟机上安装操作系统了。
注意:下载来的镜像请使用qemu 0.10.0启动系统,我试图用{zx0}版本0.12,系统无法启动。
# 我安装的是qemu 0.11.0,{dy}次无法启动,重新安装后成功启动!
启动虚拟机:( root:root)
qemu-system-mips -M mips -m 256 -kernel vmlinux-2.6.18-6-qemu -hda debian_etch_mips_small.qcow2 -append "root=/dev/hda1 console=ttyS0" -nographic
qemu: Warning, could not load MIPS bios 'mips_bios.bin' # 这个出错提示不管它,官网有说明。
Linux version 2.6.18-6-qemu (Debian 2.6.18.dfsg.1-23etch1) () (gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) #1 Fri Dec 12 23:23:12 GMT 2008
CPU revision is: 00019300
FPU revision is: 00739300
Determined physical RAM map:
memory: 10000000 @ 00000000 (usable)
Built 1 zonelists. Total pages: 65536
Kernel command line: root=/dev/hda1 console=ttyS0
Primary instruction cache 2kB, physically tagged, 2-way, linesize 16 bytes.
Primary data cache 2kB, 2-way, linesize 16 bytes.
Synthesized TLB refill handler (20 instructions).
Synthesized TLB load handler fastpath (32 instructions).
Synthesized TLB store handler fastpath (32 instructions).
Synthesized TLB modify handler fastpath (31 instructions).
Cache parity protection disabled
PID hash table entries: 2048 (order: 11, 8192 bytes)
Using 100.000 MHz high precision timer.
Console: colour VGA+ 80x25
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 256932k/262144k available (2099k kernel code, 5168k reserved, 452k data, 132k init, 0k highmem)
Security Framework v1.0.0 initialized
SELinux: Disabled at boot.
Capability LSM initialized
Mount-cache hash table entries: 512
Checking for 'wait' instruction... available.
NET: Registered protocol family 16
Linux Plug and Play Support v0.97 (c) Adam Belay
NET: Registered protocol family 2
IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 8192 bind 4096)
TCP reno registered
audit: initializing netlink socket (disabled)
audit(946684800.240:1): initialized
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
Initializing Cryptographic API
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
isapnp: Scanning for PnP cards...
isapnp: No Plug & Play device found
rtc: SRM (post-2000) epoch (2000) detected
Real Time Clock Driver v1.12ac
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
ne.c:v1.10 9/23/94 Donald Becker ()
Last modified Nov 1, 2000 by Paul Gortmaker
NE*000 ethercard probe at 0x300: 52 54 00 12 34 56
eth0: NE2000 found at 0x300, using IRQ 9.
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
hda: QEMU HARDDISK, ATA DISK drive
hdc: QEMU DVD-ROM, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
hda: max request size: 512KiB
hda: 20971520 sectors (10737 MB) w/256KiB Cache, CHS=16383/255/63
hda: cache flushes supported
hda: hda1 hda2 < hda5 >
pktgen v2.67: Packet Generator for packet performance testing.
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
kjournald starting. Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
Freeing unused kernel memory: 132k freed
INIT: version 2.86 booting
Starting the hotplug events dispatcher: udevd.
Synthesizing the initial hotplug events...done.
Waiting for /dev to be fully populated...hdc: ATAPI 4X CD-ROM drive, 512kB Cache
Uniform CD-ROM driver Revision: 3.20
done.
Activating swap...Adding 489940k swap on /dev/hda5. Priority:-1 extents:1 across:489940k
done.
Checking root file system...fsck 1.40-WIP (14-Nov-2006)
/dev/hda1: clean, 19424/1249248 files, 162071/2498099 blocks
done.
EXT3 FS on hda1, internal journal
Setting the system clock..
Cleaning up ifupdown....
Loading kernel modules...loop: loaded (max 8 devices)
done.
Loading device-mapper supportdevice-mapper: ioctl: 4.7.0-ioctl (2006-06-24) initialised:
.
Checking file systems...fsck 1.40-WIP (14-Nov-2006)
done.
Setting kernel variables...done.
Mounting local filesystems...done.
Activating swapfile swap...done.
Setting up networking....
Configuring network interfaces...done.
Starting portmap daemon....
Setting console screen modes and fonts.
INIT: Entering runlevel: 2
Starting system log daemon: syslogd.
Starting kernel log daemon: klogd.
Starting portmap daemon...Already running..
Starting MTA: exim4.
Starting internet superserver: inetd.
Starting NFS common utilities: statd.
Starting deferred execution scheduler: atd.
Starting periodic command scheduler: crond.
Debian GNU/Linux 4.0 debian-mips ttyS0
debian-mips login: root
Password:
Last login: Mon Dec 29 21:28:59 2008 on ttyS0
Linux debian-mips 2.6.18-6-qemu #1 Fri Dec 12 23:23:12 GMT 2008 mips
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
2. 建立虚拟机编译环境和mldonkey依赖库
apt-get install gcc g++ make libc6-dev # 有地方出错了,apt-get update 解决!
debian-mips:~# apt-get install gcc g++ make libc6-dev
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
binutils cpp cpp-4.1 g++-4.1 gcc-4.1 libstdc++6-4.1-dev linux-kernel-headers
Suggested packages:
binutils-doc cpp-doc gcc-4.1-locales gcc-4.1-doc manpages-dev autoconf
automake1.9 libtool flex bison gdb gcc-doc glibc-doc libstdc++6-4.1-doc
make-doc-non-dfsg
Recommended packages:
libmudflap0-dev
The following NEW packages will be installed
binutils cpp cpp-4.1 g++ g++-4.1 gcc gcc-4.1 libc6-dev libstdc++6-4.1-dev
linux-kernel-headers make
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.2MB of archives.
After unpacking 54.2MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Err etch/main libc6-dev 2.3.6.ds1-13etch8
404 Not Found
Failed to fetch 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
debian-mips:~#
apt-get install libgd2-dev libmagic-dev zlib-dev bzip2-dev
debian-mips:~# apt-get install libgd2-dev libmagic-dev zlib-dev bzip2-dev #出错
Reading package lists... Done
Building dependency tree... Done
Package libgd2-dev is a virtual package provided by:
libgd2-noxpm-dev 2.0.33-5.2etch2
You should explicitly select one to install.
E: Package libgd2-dev has no installation candidate
debian-mips:~# apt-get install libgd2-noxpm-dev # 选择这个安装就可以
debian-mips:~# apt-get install zlib-dev # 软件包名出错
Reading package lists... Done
Building dependency tree... Done
E: Couldn't find package zlib-dev
debian-mips:~# apt-get install bzip2-dev #软件包 出错
debian-mips:~# apt-get install bzip2 #正确的软件包名安装
3. 编译mldonkey
在下载代码,
wget
我使用的版本是3.0.1。其实,编译本身没有什么,
解开mlonkey的压缩包,
bunzip2 -kv mldonkey-3.0.1.tar.bz2
tar xvf mldonkey-3.0.1.tar
然后进行mlonkey目录:
./configure --enable-batch
make mlnet.byte.static
由于虚拟机运行效率问题,编译进行中................., #未完待续!。
4. 在无线路由器上运行mldonkey
请把刚编译出来的mlnet.byte.static连同虚拟机里的如下文件拷贝出来
ld.so.1, libnss_dns.so.2, libresolve.so.2 libc.so.6, libnss_files.so.2
在无线路由器上先把上述几个lib文件放置的地方加入LD_LIBRARY_PATH环境变量的。然后运行mlnet.byte.static就行了。