1
0

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 1 year has passed since last update.

Fortranのコードをコンパイルできるようにした方法 (おまけ: JupyterLab)

Posted at

fortranのコードをコンパイルしようとしたら、いろんなエラーがたくさん出てきたので、備忘録として記す。

そしてエラーに対処してたらなぜかターミナルベースのJupyterLabで図の保存ができなくなった(これまたたくさんのエラーを吐いた)ので、デスクトップアプリをダウンロードしてみた。
JupyterLabについてはおまけとして記す。

開発元を検証できないため開けない?

まず出てきたのは「"gfortran"は、開発元を検証できないため開けません」というメッセージ。
こちらを参考に対処する。

「システム環境設定」の「セキュリティとプライバシー」から手動で許可していく。
""の中身を変えてたくさん出てきたのでちまちまやる。

コンパイルエラー

ld: library not found for -lSystem
collect2: error: ld returned 1 exit status

こちらを参考に対処する。

% brew upgrade gcc

結構時間がかかる。しかし・・・

Error: Permission denied @ apply2files - /usr/local/share/ghostscript/9.10/Resource/Font/logo10.pfb

残念。

brew doctorで原因を探る

今度はこちらを参考に対処する。

% brew doctor
Warning: Your Command Line Tools are too outdated.

Warning: The following directories do not exist:
/usr/local/sbin

Warning: Broken symlinks were found. Remove them with `brew cleanup`:

指示通りやってみる。

% sudo rm -rf /Library/Developer/CommandLineTools
% sudo xcode-select --install

% sudo mkdir -p /usr/local/sbin
% sudo chown -R [ユーザ名] /usr/local/sbin

% brew cleanup
Error: Permission denied @ apply2files - /usr/local/share/ghostscript/9.10/Resource/Font/logo10.pfb

同じエラーが出てきた(ここまでこちらと同じ経過)。

% sudo chown -R [ユーザ名] /usr/local/share/ghostscript/9.10/Resource/Font/
...

同じようなエラーが出てくるたびにsudo chownをしていく。

% brew cleanup

ついに成功。

gccのupdrageをしたい

% brew upgrade gcc
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump

指示通りこちらを参考に対処する。

% sudo mkdir /opt/homebrew
% sudo chown -R [ユーザ名] /opt/homebrew
% git clone https://github.com/Homebrew/brew
% eval "$(brew shellenv)" 
% brew update --force --quiet
% chmod -R go-w "$(brew --prefix)/share/zsh"
% brew bundle dump

なんかうまくいかないので、こちらを参考にする。

% echo $SHELL
/bin/zsh
% emacs ~/.zshrc
~/.zshrc
+ export PATH="/opt/homebrew/bin:$PATH"
% source ~/.zshrc

ちなみに/opt/homebrew/brew/bin/のようになっていたので、brew下のファイルとフォルダをhomebrew下に移動した。

% brew upgrade gcc
Error: gcc not installed

% brew install gcc

できた!

fortranのコンパイル

古い.oファイルを全部消して、コンパイルし直したら成功した!

おまけ: JupyterLabのデスクトップアプリ

その後ターミナルベースのJupyterLabでsavefigをするとたくさんのエラーを吐くようになった。
少し調べてみるとJupyterLabのデスクトップアプリがあるらしい。
こちらを参考に、公式サイトのDownloadからmacOS Installerをインストールする。
とても簡単にデスクトップアプリが使えるようになり、しかもエラーを吐かなくなった。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?