1
1

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.

Arch Linux で Swift を使う

Last updated at Posted at 2017-12-25

インストール

yay swift-bin

バージョンの確認

$ swift --version
Swift version 6.0.1 (swift-6.0.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Swift の プログラム

hello.swift
// -----------------------------------------------------------------------
//	hello.swift
//
//					Dec/25/2017
// -----------------------------------------------------------------------
print("*** 開始 ***")
print("Hello world!")
print("これはテストです。")
print("*** 終了 ***")
// -----------------------------------------------------------------------

実行

$ swift hello.swift
*** 開始 ***
Hello world!
これはテストです。
*** 終了 ***

コンパイル

Makefile
hello: hello.swift
	swiftc hello.swift
clean:
	rm -f hello

コンパイル

make

実行

$ ./hello 
*** 開始 ***
Hello world!
これはテストです。
*** 終了 ***

import Glibc を使えるようにする

sudo mkdir /usr/include/x86_64-linux-gnu
sudo cd /usr/include/x86_64-linux-gnu
sudo ln -s /usr/include/sys .

確認

$ swift -I /usr/lib/swift/clang/include
  1> import Glibc
  2> random()
$R0: Int = 1804289383
  3> :quit

関連ページ
Package Details: swift-bin 6.0.1-1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?