十一
10/09
Synology DS109+ 编译安装MLDonkey
最后更新于 星期二, 10 十一月 2009 03:18
作者: sHiN3
星期二, 10 十一月 2009 03:18

当然安装MLDonkey最简单的方法是使用ipkg install命令,但是里面的MLDonkey是3.0.0版本的,而最新版是3.0.1,想使用的话只能自己手动编译安装。另外编译安装的好处是为DS109+配置好编译环境,方便以后编译其他软件。

  • 首先使用ipkg安装编译环境Tool Chains——optware-devel,它会一口气安装上N个编译环境需要用到的组件:autoconf , automake , bash , bison , bzip2 , coreutils , diffutils , file , findutils , flex , gawk , groff , gzip , libstdc++ , libtool , make , m4 , ncurses , openssl , patch , perl , pkgconfig , python25 , rsync , sed , svn , tar , wget-ssl , binutils , libc-dev , gcc
    sHiN3> ipkg install optware-devel

    Installing optware-devel (6.8-9) to root…

    An error ocurred, return value: 1.
    Collected errors:
    ERROR: The following packages conflict with wget-ssl:
    wget

    注意最后一行的错误提示,将要安装的wget-ssl与现有的wget冲突,安装脚本停止了,后果是排在后面最重要的gcc没有安装,所以还要手动安装一次

    sHiN3> ipkg install gcc
    Installing gcc (3.4.6-5) to root…
    Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/gcc_3.4.6-5_powerpc.ipk
    Installing binutils (2.17-2) to root…
    Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/binutils_2.17-2_powerpc.ipk
    Installing libc-dev (2.3.4-5) to root…
    Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/libc-dev_2.3.4-5_powerpc.ipk
    Installing libnsl (2.3.4-4) to root…
    Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/libnsl_2.3.4-4_powerpc.ipk
    Configuring binutils
    update-alternatives: Linking //opt/bin/strings to /opt/bin/binutils-strings
    Configuring gcc
    Configuring libc-dev
    Configuring libnsl
    Successfully terminated.
  • 下面开始安装MLDonkey,我实在/temp里安装的
    sHiN3> cd /temp
    sHiN3> wget http://downloads.sourceforge.net/project/mldonkey/mldonkey/3.0.1/mldonkey-3.0.1.tar.bz2?use_mirror=ncu
    –2009-11-07 15:27:48–  http://downloads.sourceforge.net/project/mldonkey/mldonkey/3.0.1/mldonkey-3.0.1.tar.bz2?use_mirror=ncu
    Resolving downloads.sourceforge.net… 216.34.181.59
    Connecting to downloads.sourceforge.net|216.34.181.59|:80… connected.
    HTTP request sent, awaiting response… 302 Found
    Location: http://ncu.dl.sourceforge.net/project/mldonkey/mldonkey/3.0.1/mldonkey-3.0.1.tar.bz2 [following]
    –2009-11-07 15:27:55–  http://ncu.dl.sourceforge.net/project/mldonkey/mldonkey/3.0.1/mldonkey-3.0.1.tar.bz2
    Resolving ncu.dl.sourceforge.net… 140.115.17.45
    Connecting to ncu.dl.sourceforge.net|140.115.17.45|:80… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 2722659 (2.6M) [application/x-bzip2]
    Saving to: `mldonkey-3.0.1.tar.bz2′

    100%[======================================>] 2,722,659   23.7K/s   in 2m 7s

    2009-11-07 15:30:04 (20.9 KB/s) – `mldonkey-3.0.1.tar.bz2′ saved [2722659/2722659]

    sHiN3> tar jvxf mldonkey-3.0.1.tar.bz2
    tar: Record size = 8 blocks
    ./mldonkey-3.0.1/

  • 下面仔细说说最重要的ocaml编译器,因为MLDonkey的源文件需要用Ocaml来编译,所以必须在编译开始之前安装上。安装方法有两种,一种是使用ipkg包,另一种是在configure MLDonkey的时候加上–enable-force-ocaml参数来强制下载编译ocaml。我先是使用第一种方法,但是在编译时出现报错,make maintainerclean后,使用–enable-force-ocaml参数后,编译成功。比较诡异的是我恢复系统后直接使用第二种方法加入–enable-force-ocaml,编译时仍旧报相同的错误,make maintainerclean后,再次加入–enable-force-ocaml参数,才编译成功。报错如下:
    File “src/daemon/common/commonMain.ml”, line 20, characters 0-12:
    Error: Unbound module Printf2

    make: *** [src/daemon/common/commonMain.cmx] Error 2

    可能大家看的比较晕,我画个表格阐述一下我两次成功编译的步骤:

    第一种方法 第二种方法
    ocaml安装方式 ipkg install ocaml 编译时加–enable-force-ocaml
    ./configure 成功 成功
    ./make printf2错误 printf2错误
    处理 ./make maintainerclean ./make maintainerclean
    第二次 ./configure ./configure –enable-force-ocaml ./configure –enable-force-ocaml
    ./make 成功编译 成功编译

    我的结论是:由于某种未知的原因,编译MLDonkey时,不管使用何种方法安装ocaml 需要按照如下步骤操作:./configure > make >
    printf2 报错 > make maintainerclean > ./configure > make 才能成功编译。

    我没有真正试验过,但是我认为如果你使用ipkg安装的ocaml了,第二次./configure的时候即使不加入–enable-force-ocaml也是可以成功编译出来的,希望有兴趣的同学给点反馈。

  • 下面我按照两次./configure 都加入–enable-force-ocmal的方法来继续安装
  • ocaml的编译时间不是一般的长,大约需要半个小时才能完成。
  • 我只想使用MLDonkey的eDonkey功能,所以加入了关闭其他功能的参数,具体的参数可以参考
    http://mldonkey.sourceforge.net/CompilationProblems

    sHiN3> cd mldonkey-3.0.1
    sHiN3> ./configure –disable-multinet –disable-donkeysui –enable-batch  –enab le-force-ocaml
    Arguments to configure:  ‘–disable-multinet’ ‘–disable-donkeysui’ ‘–enable-batch’ ‘–enable-force-ocaml’
    checking for gcc… gcc

    Now execute ‘make’ to start compiling. Good luck!

    To compile a static code execute:     make mlnet.static
    To produce a release tarball execute: make release.mlnet.static
    To clean the build directory execute: make maintainerclean

  • 再开始 make 前,需要从/opt/lib链接两个lib到/lib下,否则会提示找不到lib。

    ./ocamlpp.byte: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

    ./ocamlpp.byte: error while loading shared libraries: libbz2.so.1.0: cannot open shared object file: No such file or directory

  • 使用ln -s命令链接这两个lib
    sHiN3> ln -s /opt/lib/libz.so.1.2.3 /lib/libz.so.1

    sHiN3> ln -s /opt/lib/libbz2.so.1.0.5 /lib/libbz2.so.1.0

  • 执行 ./make 等待报错吧
    sHiN3> make

    ./ocamlpp.byte -pp src/networks/gnutella2/g2Functions.mlt > src/networks/gnutella2/g2Functions.ml


    File “src/daemon/common/commonMain.ml”, line 20, characters 0-12:
    Error: Unbound module Printf2
    make: *** [src/daemon/common/commonMain.cmx] Error 2

  • 执行 make maintainerclean 清除 configure生成的文件,再次 configure,然后 make
    sHiN3> make maintainerclean

    sHiN3> ./configure –disable-multinet –disable-donkeysui –enable-batch  –enab le-force-ocaml

    sHiN3> make

    -cclib -lmagic \
    -I build    build/cdk.cmxa    build/magic.cmxa    build/common.cmxa    build/client.cmxa    build/core.cmxa    build/driver.cmxa    src/daemon/common/commonMain.cmx
  • 编译成功,这是在当前目录下(/temp)就得到了mlnet这个bin文件,此时还需要链接一个lib到/lib,否则执行的时候报错
    sHiN3> ln -s /opt/lib/libmagic.so.1.0.0 /lib/libmagic.so.1
  • 此时运行 mlnet,成功启动MLDonkey
    sHiN3> ./mlnet
    2009/11/08 21:22:45 [cO] Starting MLDonkey 3.0.1 …
    2009/11/08 21:22:45 [cO] Language EN, locale ANSI_X3.4-1968, ulimit for open files 1024
    2009/11/08 21:22:45 [cO] MLDonkey is working in /root/.mldonkey

    2009/11/08 21:22:45 [cO] creating new MLDonkey base directory in /root/.mldonkey

    2009/11/08 21:22:45 [cO] loaded language resource file
    2009/11/08 21:22:45 [DNS] Resolving [sHiN3] …
    2009/11/08 21:22:45 [DNS] Resolving [www.mldonkey.org] …
    2009/11/08 21:22:46 [dMain] Libmagic file-type recognition database present
    2009/11/08 21:22:46 [cO] Logging in /root/.mldonkey/mlnet.log
    2009/11/08 21:22:46 [dMain] Core started

  • 注意这行:[cO] Language EN, locale ANSI_X3.4-1968,说明现在MLDonkey使用的语言环境是英文,ANSI字符编码,这会造成下载的中文文件名变成下划线,而DS109+的Linux环境下又缺少locale模块,下一篇文章将会介绍如何加入缺少的glibc locale模块。


发表评论