2013年1月20日 星期日

Install sumo on CentOS 6.x (搞定)

懶人包:建議直接換回Ubuntu裝sumo比較快,我已經懶得處理各套件之間衝突的問題了

發現可以成功安裝的方法了,這邊更新一下安裝成功的方式,一樣是在sumo的官方網站下載,下載的是sumo-src-0.16.0.tar.gz,方法如下:
$ tar zxvf sumo-src-0.16.0.tar.gz
$ cd sumo-0.16.0/
$ ./configure
...
...
checking for XERCES... no
checking for main in -lxerces-c... no
configure: error: xerces-lib not found. Specify path with option --with-xerces-libraries=DIR.
因為缺了xerces所以沒辦法裝,在這邊可以下載,為了保險起見,還是抓原始檔自己編譯好。

$ tar zxvf xerces-c-3.1.1.tar.gz
$ cd xerces-c-3.1.1
$ ./configure
$ sudo make install

再來回到sumo資料夾底下sudo make install就可以了
$ cd sumo-0.16.0
$ ./configure(註)
$ sudo make install
這時來測試sumo有沒有正常運作
$ sumo
sumo: error while loading shared libraries: libxerces-c-3.1.so: cannot open shared object file: No such file or directory
sumo找不到xerce-lib的位置,上面裝好之後,應該會放在/usr/local/lib/裡面,不確定的話,可以用find找一下
$ find / -name libxerces-c-3.1.so
假設一樣是在/usr/local/lib,那就把這路徑存到環境變數LD_LIBRARY_PATH裡面,以下是bash的作法
$ export LD_LIBRARY_PATH=/usr/local/lib
如果是csh或其他shell,就請google找 csh path 應該可以找的到作法。
但是這樣的作法每開一次shell都要設定一次,且/usr/local/lib這個位置以後應該還會放很多自己安裝的library,所以提供一個一勞永逸的方法(重灌後無效廢話
cd /etc/ld.so.conf.d/
sudo vim usr.local.lib.conf
直接打上 /usr/local/lib 存檔離開,然後使用以下指令讓系統重整一下cache
$ sudo ldconfig
這樣sumo就算安裝完成,可以成功執行了
bency@lab:lib 00:14:43
$ sumo
SUMO sumo Version 0.16.0
 Copyright (C) 2001-2012 DLR and contributors; http://sumo.sourceforge.net
 License GPLv3+: GNU GPL Version 3 or later 
 Use --help to get the list of options.

註: 畫面跑很快,所以看不清楚,沒關係,我有節錄一些之前處理相依處理到頭很大的相關訊息
configure: WARNING: proj-lib not found. Specify path with option --with-proj-libraries=DIR.
configure: WARNING: proj-includes not found. Specify path with option --with-proj-includes=DIR.
configure: WARNING: gdal-lib not found. Specify path with option --with-gdal-libraries=DIR.
configure: WARNING: gdal-includes not found. Specify path with option --with-gdal-includes=DIR.
configure: WARNING: fox-lib not found. Specify path with option --with-fox-libraries=DIR for gui applications.
configure: WARNING: fox-includes not found. Specify path with option --with-fox-includes=DIR for gui applications.
可以看到總共有三個library沒裝:
  1. proj-lib:這是用來把地球立體座標轉換成平面座標用的(來源)
  1. gdal-lib:Geospatial Data Abstraction Library
  1. fox-lib:GUI介面套件
所以少這三樣沒裝的話,可能就沒辦法使用到這些功能了,就看自己需求吧,就算沒裝還是可以把sumo裝好使用


以下是失敗過程,因為打很久,所以捨不得刪,可以不用看沒關係


這個網站有提供各個平台適用的連結,如果找不到自己的平台,看是要裝vm跑還是直接抓原始檔自己編,不過現在要記錄的是在CentOS 6.x 上安裝sumo。
我抓的檔案是 sumo-0.16.0-7.1.x86_64.rpm,首先是用rpm安裝
bency@lab:tmp 02:37:55
$ sudo rpm -i sumo-0.16.0-7.1.x86_64.rpm 
[sudo] password for bency: 
警告:sumo-0.16.0-7.1.x86_64.rpm: 表頭 V3 DSA/SHA1 Signature, key ID 559bc40e: NOKEY
錯誤:相依性偵測失敗:
        libFOX-1.6.so.0()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libfreexl.so.1()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libgdal.so.1()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libgeos-3.3.6.so()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libgeos_c.so.1()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libgif.so.4()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libhdf5.so.7()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libnetcdf.so.7()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libodbc.so.2()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libodbcinst.so.2()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libpq.so.5()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libproj.so.0()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libspatialite.so.5()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
        libxerces-c-3.0.so()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
由此可見有很多相依需要處理,以下是各個有缺的套件安裝方式或載點:


  1. libFOX-1.6 參考來源
    • http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/ 下載最新版本的rpmforge-release-xxxxxx.rpm
    • sudo rpm -Uvh rpmforge-release-xxxxxx.rpm
    • sudo yum install fox
    • PS:剛剛才發現rpmforge有x64(連結在這)的版本,不過我已經裝了i686版本,還不知道會不會有問題,等等裝完就知道了
  2. libfreexl.so 參考來源
    • http://download.fedora.redhat.com/pub/epel/6/x86_64/下載最新版本的epel-release-xxx.rpm
    • 以上連結失效,請到這邊http://dl.fedoraproject.org/pub/epel/6/x86_64/下載
    • sudo rpm -Uvh epel-release-xxx.rpm
    • PS:雖然會出現警告,但實際上已經裝進去了
    • sudo yum install freexl
  3. libgdal.so
    • 因為剛剛裝了epel-release-xxx.rpm,所以yum已經找的到,直接裝就行了
    • sudo yum install gdal.x86_64
    • 如果名稱不對,可以用yum search gdal  查詢正確的名稱
    • 因為這隻相依的套件有點多
      Installed:
        gdal.x86_64 0:1.7.3-15.el6                                                                                                                                                         
      
      Dependency Installed:
        cfitsio.x86_64 0:3.240-3.el6                   environment-modules.x86_64 0:3.2.7b-6.el6        geos.x86_64 0:3.3.2-1.el6              giflib.x86_64 0:4.1.6-3.1.el6            
        hdf5-mpich2.x86_64 0:1.8.5.patch1-7.el6        libdap.x86_64 0:3.11.0-1.el6                     libgeotiff.x86_64 0:1.2.5-5.el6        libgfortran.x86_64 0:4.4.6-4.el6         
        librx.x86_64 0:1.5-14.el6                      mpich2.x86_64 0:1.2.1-2.3.el6                    netcdf.x86_64 0:4.1.1-3.el6.2          ogdi.x86_64 0:3.2.0-0.14.beta2.el6       
        postgresql-libs.x86_64 0:8.4.13-1.el6_3        proj.x86_64 0:4.7.0-1.el6.rf                     tcl.x86_64 1:8.5.7-6.el6               unixODBC.x86_64 0:2.2.14-12.el6_3        
        xerces-c.x86_64 0:3.0.1-20.el6                
      
      Complete!
      所以就剩下
              libgeos-3.3.6.so()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
              libhdf5.so.7()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
              libnetcdf.so.7()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
              libspatialite.so.5()(64bit) 被 sumo-0.16.0-7.1.x86_64 所需要
      需要裝了
  4. libgeos-3.3.6.so
    • gdal相依的是3.3.1的版本,但現在要的是3.3.6,所以需要另外手動下載安裝 參考來源(抱歉這是錯的)
    • wget http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/i386/os/Packages/g/geos-3.3.6-1.fc19.i686.rpm
    • 要抓的應該是這個才對
      $ sudo rpm -i geos-3.3.6-1_0.el6.x86_64.rpm  
      
    • 順利裝完就可以了
  5. libhdf5.so.7
    • 這也包含在rpmforge裡面,所以直接下指令安裝就可以了
      $ sudo yum install hdf5.x86_64
      
  6. libnetcdf.so.7
    • netcdf 這可以直接在yum上直接安裝,但會出現以下錯誤:
      $ sudo yum install netcdf.x86_64
      [sudo] password for bency:
      Sorry, try again.
      [sudo] password for bency:
      Loaded plugins: fastestmirror, refresh-packagekit, security
      Loading mirror speeds from cached hostfile
       * base: mirror01.idc.hinet.net
       * epel: mirror01.idc.hinet.net
       * extras: mirror01.idc.hinet.net
       * rpmforge: mirror.fairway.ne.jp
       * updates: mirror01.idc.hinet.net
      Setting up Install Process
      Resolving Dependencies
      --> Running transaction check
      ---> Package netcdf.x86_64 0:4.1.1-3.el6.2 will be updated
      --> Processing Dependency: libnetcdf.so.6()(64bit) for package: gdal-1.7.3-15.el6.x86_64
      ---> Package netcdf.x86_64 0:4.1.2-1.el6.rf will be an update
      --> Finished Dependency Resolution
      Error: Package: gdal-1.7.3-15.el6.x86_64 (@epel)
                 Requires: libnetcdf.so.6()(64bit)
                 Removing: netcdf-4.1.1-3.el6.2.x86_64 (@epel)
                     libnetcdf.so.6()(64bit)
                 Updated By: netcdf-4.1.2-1.el6.rf.x86_64 (rpmforge)
                     Not found
       You could try using --skip-broken to work around the problem
       You could try running: rpm -Va --nofiles --nodigest
      
    • 就算是加上
      --skip-broken
      也沒辦法找到libnetcdf.so.7()(64bit)
    • 不過看上面的錯誤訊息,應該是netcdf-4.1.1-3.el6.2.x86_64 (@epel)裡面沒有包含libnetcdf.so.7()(64bit),但gdal又需要libnetcdf.so.6()(64bit),所以先把gdal移除再裝裝看吧。
    • 移除後直接用yum安裝netcdf,會從rpmforge下載安裝。
    • 但是這下換gdal相容失敗了,所以目前這我還不知道該怎麼解決。
  7. libpatialite.so.5
    • 這被包含在libspatialite-4.0.0-1.fc19.x86_64.rpm裡面,yum上找到的版本太舊了,不包含sumo所需的libspatialite.so.5()(64bit),所以請到這邊下載
    • $ sudo rpm -i libspatialite-4.0.0-1.fc19.x86_64.rpm
      錯誤:相依性偵測失敗:
              libc.so.6(GLIBC_2.14)(64bit) 被 libspatialite-4.0.0-1.fc19.x86_64 所需要
      所以就來裝glibc吧。
    • $ sudo yum install glibc.x86_64
      Loaded plugins: fastestmirror, refresh-packagekit, security
      Loading mirror speeds from cached hostfile
       * base: mirror01.idc.hinet.net
       * epel: mirror01.idc.hinet.net
       * extras: mirror01.idc.hinet.net
       * rpmforge: mirror.fairway.ne.jp
       * updates: mirror01.idc.hinet.net
      Setting up Install Process
      Package glibc-2.12-1.80.el6_3.6.x86_64 already installed and latest version
      Nothing to do

沒有留言:

張貼留言