ラベル GNU の投稿を表示しています。 すべての投稿を表示
ラベル GNU の投稿を表示しています。 すべての投稿を表示

2018年10月30日火曜日

[macOS] macOS High Sierra にOctaveをインストール

macOS High SierraにOctaveをインストールした際のメモです.
インストールは,Homebrewを使用して行います.

先ずは,gnuplotで描画する際に AquatermかXQuartzのどちらを使うか分からないので,両方インストールしておきます.

ターミナルを立ち上げ,以下のようにコマンドを入力していきます.
この例では,Aquatermが既にインストールされていたので,"reinstall"としています.
$ brew cask reinstall aquaterm

インストールされていない場合は,"install"とします.
$ brew cask install aquaterm

すると,以下のようにインストールが実行されます.
==> Tapping caskroom/cask
...
...
🍺  aquaterm was successfully installed!
上記の"..."は,そのような表示となるわけではなく,省略を意味します.

続いて,XQuartzをインストールします.
$ brew cask install xquartz
この場合も,すでにインストールされている場合は,"reinstall"とする.

すると,以下のようにインストールが実行されます.
Updating Homebrew...
...
...
🍺  xquartz was successfully installed!
先の例と同じく,"..."は省略です.

続いて,描画に用いるgnuplotをインストールします(この場合も,既にインストールされていた場合の例( i.e. "reinstall")なので,初めての場合は"install"とします).
$ brew reinstall gnuplot --with-aquaterm --with-x11
==> Reinstalling gnuplot --with-aquaterm --with-x11
...
🍺  /.../.../.../gnuplot/5.2.3: 47 files, 2.7MB, built in 1 minute 22 seconds
("..."は省略です)

そして,Octaveをインストールします.
$ brew install octave

ズラズラと,表示が流れ,インストールが進み,最後に以下のような表示があってインストールは完了します.
🍺  /.../.../.../octave/4.4.0: 2,173 files, 45.4MB

Octaveを立ち上げるには,"octave"と入力します.
$ octave
そして,以下のように立ち上がればインストール成功です.
GNU Octave, version 4.4.0
Copyright (C) 2018 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-apple-darwin17.5.0".

Additional information about Octave is available at https://www.octave.org.

Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html

Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> exit
(Octaveを終了するには,上記のように"exit"と入力します)

2016年11月26日土曜日

[Mac] macOS Sierra にgccをインストール

macOS Sierra にgccをインストールした際のメモです.
インストールはHomebrewを用いて行いました.

ターミナルから,以下コマンドを実行します.
$ brew install gcc

インストールは,意外とあっさりと終了します.

確認のために,以下のコマンドを実行すると,gfortranのインストールされている場所を教えてくれます.

$ which gfortran
/usr/local/bin/gfortran


だめ押しに,お決まりのHello World! を実行してみました.
以下のプログラムをデスクトップ"hello.f90"という名前で保存します.

program hello

  print *, 'Hello World!'

end program hello

ターミナルから,以下のコマンドを実行すると,無事,"Hello World!"と表示されました.

$ gfortran hello.f90
$ ./a.out
 Hello World!

2018.12.11. 追記
macOS Mojave にgccをインストールした際のインストール画面は以下のようなものでした.
$ brew install gcc
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
hub                                      oniguruma

==> Installing dependencies for gcc: gmp, isl, mpfr and libmpc
==> Installing gcc dependency: gmp
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.1.2_2.mojave.bottle.t
######################################################################## 100.0%
==> Pouring gmp-6.1.2_2.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/gmp/6.1.2_2: 18 files, 3.1MB
==> Installing gcc dependency: isl
==> Downloading https://homebrew.bintray.com/bottles/isl-0.20.mojave.bottle.tar.
######################################################################## 100.0%
==> Pouring isl-0.20.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/isl/0.20: 71 files, 3.9MB
==> Installing gcc dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-4.0.1.mojave.bottle.ta
######################################################################## 100.0%
==> Pouring mpfr-4.0.1.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/mpfr/4.0.1: 28 files, 4.6MB
==> Installing gcc dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.1.0.mojave.bottle.
######################################################################## 100.0%
==> Pouring libmpc-1.1.0.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/libmpc/1.1.0: 12 files, 354KB
==> Installing gcc
==> Downloading https://homebrew.bintray.com/bottles/gcc-8.2.0.mojave.bottle.1.t
######################################################################## 100.0%
==> Pouring gcc-8.2.0.mojave.bottle.1.tar.gz
🍺  /usr/local/Cellar/gcc/8.2.0: 1,413 files, 295.5MB

2015年7月24日金曜日

[gcc] Mac OS X (Yosemite)にXcodeをインストール

macOS Sierra でもインストール方法は同様です(24, Sep. 2017)

インストール方法
最初に,統合開発環境(IDE、Integrated Development Environment)である「Xcode」をインストールした後に,Command Line Tools をインストールします.

手順は,以下のようになります.
  • インストールしたXcodeを起動
  • 上部メニューから,"Xcode" ->"Open Debeloper Tool" -> "More Developer Tools..."をクリック
  • ブラウザが起動し,Apple Develper ページが表示されるので,Apple ID,Passwordを入力し,"Sign in"をクリックしてサインイン
  • "Downloads for Apple Developers"というページが表示されるので,その中から"Command Line Tools for Xcode"の .dmgファイルをダウンロード
  • ダウンロードした .dmgファイルを開き,pkgファイルを実行
  • インストーラが起動するので,「続ける」をクリック
  • 使用許諾契約などに対して「続ける」,「同意する」をクリックして,最後に「インストール」をクリック
ターミナルからCommand Line Tools をインストールするには,
$ xcode-select --install
とします.
すでにインストールされている場合は,以下のようにかえってきます.
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
続いてMacPortsやHomebrewを用いてYosemiteに対応したインストーラーをダウンロードしてインストールを行います.

MacPortsの場合
MacPortsがインストールされているかどうかを確認するには,
$ port -v
MacPorts 2.3.3
Entering interactive mode... ("help" for help, "quit" to quit)
[Users/xxx] > quit
Goodbye
とします.

MacPortsがインストールされていることを確認した上で,最新のgccのバージョンを確認するには,$ port search gcc とすると,以下のようになるので,最新バージョンを探します(この時点ではgcc49が最新).
$ port search gcc
apple-gcc40 @5494 (lang)
    Apple's version of gcc 4.0

apple-gcc42 @5666.3_15 (lang)
    Apple's version of gcc 4.2

...(ここには,過去のバージョンのリストが表示されます)...

gcc48 @4.8.5 (lang)
    The GNU compiler collection

gcc49 @4.9.3 (lang)
    The GNU compiler collection

gcc410 @5-20140817 (lang)
    this port is only a stub and has been made obsolete by gcc5

...(ここにも,β版等のリストが表示されます)...
インストールしたいバージョンを選んで,以下のように入力するとインストールが始まります.

$ sudo port install gcc**
**はバージョン(49など)

mp-gccをアクティブにしたい場合は,インストールが完了したら,
$ sudo port select --list gcc
Password:
Available versions for gcc:
mp-gcc49
none (active)
と表示されるので,


$ sudo port select gcc mp-gcc49
Selecting 'mp-gcc49' for 'gcc' succeeded. 'mp-gcc49' is now active.
とすれば,mp-gcc49がアクティブになります.

インストールの成功を確認する方法
テキストエディタを使って,以下のプログラム(helloc.c)を作成し,ファイルをデスクトップに保存します.

#include<stdio.h>
   int main() {
     printf("Hello, World\n");
     return 0;
   }

続いて,ターミナルを起動して,cdコマンドで作業ディレクトリをデスクトップに移動し,gccコマンドで,helloc.cをコンパイルします.
$ cd desktop
$ gcc helloc.c
コンパイルが成功すると,実行ファイル(a.out)が作成されるので,これを実行します.

$ ./a.out

これで,
$ ./a.out
Hello, World
と表示されれば,インストールが成功していることが確認できます.

gfortranの場合は,以下のプログラム(hellof.f90)を作成し,ファイルをデスクトップに保存します.

program hello
  print *, 'Hello World!'
end program hello

続いて,ターミナルを起動して,cdコマンドで作業ディレクトリをデスクトップに移動し,gccコマンドで,hellof.cをコンパイルします.
$ cd desktop
$ gfortran hellof.f90

コンパイルが成功すると,実行ファイル(a.out)が作成されるので,これを実行します.
$ ./a.out

これで,
$ ./a.out
Hello, World
と表示されれば,インストールが成功していることが確認できます.