4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ld: library not found for -lgfortran と出た時の対処法(Mac OS Mojave 10.14.3)

Posted at

##背景

Rで統計用パッケージ(TSSS)をインストールしようとした時に色々と手間取ったのでその備忘録.

##問題点

RでTSSSをインストールしようとすると

> install.packages("TSSS",dependencies=TRUE)

-lgfortran がないと怒られてしまう

ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [TSSS.so] Error 1
ERROR: compilation failed for package ‘TSSS’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/TSSS’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/TSSS’

##解決法

gcc gfortran のver.を落として,シンボリックリンクを作成してあげれば良い

まず brew で 'gcc-4.9' をインストールする.

brew install gcc@4.9

次にシンボリックリンクを作成する.

#gccなどのver.を4.9に揃える
ln -fs /usr/local/bin/gcc-4.9 /usr/local/bin/gcc
ln -fs /usr/local/bin/g++-4.9 /usr/local/bin/g++
ln -fs /usr/local/bin/gfortran-4.9 /usr/local/bin/gfortran

#lgfortranを使えるようにする.
ln -fs /usr/local/lib/gcc/4.9/libgfortran.dylib /usr/local/lib/libgfortran.dylib
ln -fs /usr/local/lib/gcc/4.9/libgfortran.a /usr/local/lib/libgfortran.a
ln -fs /usr/local/lib/gcc/4.9/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib
ln -fs /usr/local/lib/gcc/4.9/libgfortran.spec /usr/local/lib/libgfortran.spec

#TSSSのインストールしようとしたらld: library not found for -lquadmathとも怒られたのでシンボリックリンク作成.
ln -fs /usr/local/lib/gcc/4.9/libquadmath.0.dylib /usr/local/lib/libquadmath.0.dylib
ln -fs /usr/local/lib/gcc/4.9/libquadmath.a /usr/local/lib/libquadmath.a
ln -fs /usr/local/lib/gcc/4.9/libquadmath.dylib /usr/local/lib/libquadmath.dylib

##結果

installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/TSSS/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (TSSS)

やったねヽ(・∀・)ノ

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?