R語言中GCC編譯的問題(續)

2021-09-29 03:43:58 字數 2219 閱讀 5801

這篇文章承接r語言中gcc編譯的問題,這篇文章主要解決我在linux系統上安裝"expm"出現的問題。

出現的問題

這個問題非常的有趣,因為我在兩台伺服器分別安裝同乙個包,其中一台沒有任何問題,而另一台則失敗,儘管作業系統都是「centos linux release 7.4.1708 (core)」。不過我知道,一定還有一些差異我沒有發現,有可能是r的版本不同,有可能是安裝r所用的gcc版本不同,但是這種差異就算知道了也不像去解決,我可不想為了乙個r包重灌系統。

那麼如何解決這個問題呢?策略就是手動安裝了。

wget 

tar xf expm_0.999-2.tar.gz

然後找到locale.h中報錯行, 也就是從libintl.h中呼叫的dgettext報錯了

#include #ifdef enable_nls

#include #define _(string) dgettext ("expm", string)

#else

#define _(string) (string)

#endif

這個libintl.h憑我本能的直覺我認為是應該是在/usr/include/下, 使用vim開啟並查詢"lc_messages"

...

/* we need lc_messages for `dgettext'. */

# include ...

這行**告訴我們這個"lc_messages"在locale.h下, 但是我發現在locale.h裡面是有定義的

/* these are the possibilities for the first argument to setlocale.

the code assumes that the lowest lc_* symbol has the value zero. */

#define lc_ctype __lc_ctype

#define lc_numeric __lc_numeric

#define lc_time __lc_time

#define lc_collate __lc_collate

#define lc_monetary __lc_monetary

#define lc_messages __lc_messages

#define lc_all __lc_all

#define lc_***** __lc_*****

#define lc_name __lc_name

#define lc_address __lc_address

#define lc_telephone __lc_telephone

#define lc_measurement __lc_measurement

#define lc_identification __lc_identificatio

於是我崩潰了。

突然間我靈機一閃,為啥不直接把這個定義新增到原來的locale.h裡呢? 於是我在locale.h裡增加了一行,改為

/* localization */

#define lc_messages "en_us.utf-8"

#include #ifdef enable_nls

#include #define _(string) dgettext ("expm", string)

#else

#define _(string) (string)

#endif

最後用r cmd install安裝

r cmd install  expm/
順利安裝!

R語言中的引號

aa this is an example.1 this is an example.bb this is an example.1 this is an example.identical aa,bb 1 true anne s home 1 anne s home anne s home 1 a...

R語言中的陣列

陣列 不同於矩陣和資料框,維度大於2。r中最簡單的陣列 3維。行,列,面 如下兩行 三列 四面的陣列。dim1 c a1 a2 dim2 c b1 b2 b3 dim3 c c1 c2 c3 c4 dat array 1 24,c 2,3,4 dimnames list dim1,dim2,dim3...

R語言 認識R語言的編譯環境

rstudio有一些常用快捷鍵,掌握這些快捷鍵可以提高編碼效率。如 1 ctrl r 可以替代run的功能,執行選中的多行或者游標所在單行的 2 ctrl shift n 建立空白文字 3 ctrl o 開啟件選擇器 4 ctrl l 清除r命令列控制台的螢幕內容 5 ctrl shift r 在游...