For most Linux binaries, NCL was built using gcc and gfortran. This may cause a dependency on a file called "libgfortran.so.x".
If you have a different version of gfortran installed on your system than what NCL was built with, then you may get an error message that "libgfortran.so.x can't be found".
If you see this, then you can try one of these things:
Try to find the libgfortran.so.x file that it is complaining about. You can try the "locate" command. For example if the file is "libgfortran.so.1":
locate libgfortran.so.1
If found, add this path to your LD_LIBRARY_PATH environment variable.
For example, if "libgfortran.so.1" is the file you need, and it is in /usr/local/lib, then look at the instructions below, depending on what shell you are running, and depending on whether LD_LIBRARY_PATH is already set:
env | grep LD_LIBRARY_PATH
From csh or tcsh, if not set:
setenv LD_LIBRARY_PATH /usr/local/lib
From csh or tcsh, if already set:
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:
/usr/local/lib
From bash or ksh, if not set:
export LD_LIBRARY_PATH=/usr/local/lib
From bash or ksh, if already set:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
From sh, if not set:
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
From sh, if already set:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
Install the "compat-libgfortran" runtime library. See one of these sites for starters:
http://rpmfind.net/linux/rpm2htm ... mpat-libgfortran-41
https://admin.fedoraproject.org/ ... 7a1a58108960859779f
Install the version of gfortran that your version of NCL was built with. (It is possible to have multiple versions of gfortran installed on the same system without conflict.)
It may then be necessary to set the LD_LIBRARY_PATH environment variable to the path of the "libgfortran.so.x" file.
If all else fails, then send email to ncl-install@ucar.edu. You need to be a member in order to post
PATH和LD_LIBRARY_PATH本質都是變量,所謂變量的意思就是由別人賦值產生的,直覺每每會讓咱們添加和減小這個變量自己的某些路徑,實際上這是不正確的。正確的作法是咱們要去修改賦予這個變量數值的那些配置文件,加一條路徑或者減一條。說到底變量只關乎顯示,不關乎其用於顯示的內容。html
PATH: 可執行程序的查找路徑mysql
查看當前環境變量:linux
echo $PATHsql
設置: shell
方法一: export PATH=PATH:/XXX 可是登出後就失效windows
方法二:修改~/.bashrc或~/.bash_profile或系統級別的/etc/profile緩存
1. 在其中添加例如export PATH=/opt/ActivePython-2.7/bin:$PATHbash
2. source .bashrc (Source命令也稱爲「點命令」,也就是一個點符號(.)。source命令一般用於從新執行剛修改的初始化文件,使之當即生效,而沒必要註銷並從新登陸)服務器
LD_LIBRARY_PATH: 動態庫的查找路徑eclipse
設置:
方法一: export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/XXX 可是登出後就失效
方法二: 修改~/.bashrc或~/.bash_profile或系統級別的/etc/profile
1. 在其中添加例如export PATH=/opt/ActiveP/lib:$LD_LIBRARY_PATH
2. source .bashrc (Source命令也稱爲「點命令」,也就是一個點符號(.)。source命令一般用於從新執行剛修改的初始化文件,使之當即生效,而沒必要註銷並從新登陸)
方法三:這個沒有修改LD_LIBRARY_PATH可是效果是同樣的實現動態庫的查找,
1. /etc/ld.so.conf下面加一行/usr/local/mysql/lib
2. 保存事後ldconfig一下(ldconfig 命令的用途,主要是在默認搜尋目錄(/lib和/usr/lib)以及動態庫配置文件/etc/ld.so.conf內所列的目錄下,搜索出可共享的動態連接庫(格式如前介紹,lib*.so*),進而建立出動態裝入程序(ld.so)所需的鏈接和緩存文件.緩存文件默認爲/etc/ld.so.cache,此文件保存已排好序的動態連接庫名字列表.)
方法三設置稍微麻煩,好處是比較不受用戶的限制。
今天用set設置PATH變量(加一個路徑),發現雖然echo的時候顯示修改爲功了,實際執行命令的時候確沒有去那個路徑查找;當前shell是c shell(csh).
setenv中的env就是環境environment的簡寫,這個命令是用來設置環境變量的,譬如說設置文件路徑、本地顯示啊什麼的,舉個例,若是想調用服務器的軟件在本地顯示,用這個命令:setenv DISPLAY 1xx.1xx.1xx.1xx:0 。在bash中export命令和csh中的setenv命令相似。
4。環境變量和內部變量:後者不能被子進程繼承(如同C裏的局部變量)--改環境變量就會自動改內部變量,反之否則。「set」可給出內部變量列表,「env」可給出環境變量列表。繼承只對環境變量有效
sh: PATH=/usr/bin:$PATH ; export PATH--注意:在export前爲內部變量,以後爲環境變量。
Csh: set setenv PATH /usr/bin:$PATH--注意: 在csh中環境變量的賦值(setenv)沒有等號, 而內部變量的賦值(set)有等號。
Linux 運行的時候,是如何管理共享庫(*.so)的?在 Linux 下面,共享庫的尋找和加載是由 /lib/ld.so 實現的。 ld.so 在標準路經(/lib, /usr/lib) 中尋找應用程序用到的共享庫。
可是,若是須要用到的共享庫在非標準路經,ld.so 怎麼找到它呢?
目前,Linux 通用的作法是將非標準路經加入 /etc/ld.so.conf,而後運行 ldconfig 生成 /etc/ld.so.cache。 ld.so 加載共享庫的時候,會從 ld.so.cache 查找。
傳統上,Linux 的先輩 Unix 還有一個環境變量:LD_LIBRARY_PATH 來處理非標準路經的共享庫。ld.so 加載共享庫的時候,也會查找這個變量所設置的路經。
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib
export LD_LIBRARY_PATH
可是,有很多聲音主張要避免使用 LD_LIBRARY_PATH 變量,尤爲是做爲全局變量。這些聲音是:
* LD_LIBRARY_PATH is not the answer - http://prefetch.net/articles/linkers.badldlibrary.html
* Why LD_LIBRARY_PATH is bad - http://xahlee.org/UnixResource_dir/_/ldpath.html
* LD_LIBRARY_PATH - just say no - http://blogs.sun.com/rie/date/20040710
解決這一問題的另外一方法是在編譯的時候經過 -R<path> 選項指定 run-time path。
1. 往/lib和/usr/lib裏面加東西,是不用修改/etc/ld.so.conf的,可是完了以後要調一下ldconfig,否則這個library 會找不到
2. 想往上面兩個目錄之外加東西的時候,必定要修改/etc/ld.so.conf,而後再調用ldconfig,否則也會找不到。
好比安裝了一個mysql到/usr/local/mysql,mysql有一大堆library在/usr/local/mysql/lib下 面,這時就須要在/etc/ld.so.conf下面加一行/usr/local/mysql/lib,保存事後ldconfig一下,新的 library才能在程序運行時被找到。
3. 若是想在這兩個目錄之外放lib,可是又不想在/etc/ld.so.conf中加東西(或者是沒有權限加東西)。那也能夠,就是export一個全局變 量LD_LIBRARY_PATH,而後運行程序的時候就會去這個目錄中找library。通常來說這只是一種臨時的解決方案,在沒有權限或臨時須要的時 候使用。
4. ldconfig作的這些東西都與運行程序時有關,跟編譯時一點關係都沒有。編譯的時候仍是該加-L就得加,不要混淆了。
5. 總之,就是無論作了什麼關於library的變更後,最好都ldconfig一下,否則會出現一些意想不到的結果。不會花太多的時間,可是會省不少的事。
LD_LIBRARY_PATH 這個環境變量是你們最爲熟悉的,它告訴loader:在哪些目錄中能夠找到共享庫。能夠設置多個搜索目錄,這些目錄之間用冒號分隔開。在linux下,還 提供了另一種方式來完成一樣的功能,你能夠把這些目錄加到/etc/ld.so.conf中,而後調用ldconfig。固然,這是系統範圍內全局有效 的,而環境變量只對當前shell有效。按照慣例,除非你用上述方式指明,loader是不會在當前目錄下去找共享庫的,正如shell不會在當前目前找 可執行文件同樣。
================================================================================================
在shell下嘗試設置LD_LIBRARY_PATH,如下面這種形式設置,總是報錯bash: LD_LIBRARY_PATH: command not found,
LD_LIBRARY_PATH=/usr/local/lib
LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/lib
多是由於系統以前沒有設置過LD_LIBRARY_PATH,因而改爲這樣:
export LD_LIBRARY_PATH=/usr/local/lib
而後用 echo $LD_LIBRARY_PATH檢查一下是否真的設置成功,發現能夠。
接着在該shell下運行eclipse生成的可執行文件,沒有錯誤。
另外,若是不想每次新啓一個shell都設置LD_LIBRARY_PATH,能夠編輯~/.bash_profile文件:
$ vi ~/.bash_profile
添加:
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
這兩行,完成以後.bash_profile以下所示:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
LD_LIBRARY_PATH=/usr/local/lib
export PATH
export LD_LIBRARY_PATH
可是這種方法只能用在shell下,想在eclipse裏面運行,仍是不行:
嘗試了eclipse項目properties裏面的各類設置都不起做用。
用「eclipse LD_LIBRARY_PATH」做爲關鍵字(可見關鍵字多麼重要)才搜到這麼篇文章 《eclipse+cdt+gcc編譯選項控制》 http://hi.baidu.com/zsffei/blog/item/7b17c043ceb51e1772f05de1.html
才知道應該在eclipse的項目屬性-->C/C++ Build-->Settings-->Tool settings-->GCC C++ Linker-->Miscellaneous的Other options (-Xlinker [option])添加 -R/usr/local/lib
運行,一切正常,折騰了一下午,太感動了。