Linux平臺swift語言開發學習環境搭建
摘要
介紹在Ubuntu平臺搭建Swift開發環境; 介紹Swift指令碼解析器swift的使用; 介紹Swift編譯器swiftc的使用;
1.序言
這兩天一直忙,沒來得及記錄東西,週三12月4日凌晨1點多看到蘋果正式開源了Swift,國外各大媒體資訊動作超級快。我也興奮的起來看了一遍關於Swift開源的最新訊息。眾所周知,蘋果平臺的Swift語言已經出來了一年半了,一直在成長,經歷了好幾個版本。許多人盼望的swift開源是希望可以在除了蘋果平臺之外的平臺可以運用這個新語言。比如有人希望將來可以用swift也可以擼一擼後臺開發之類,理論上是沒問題的,但是同樣也有人會噴這麼一個願景,但是開源一出後,多多少少社群人員會去往這個方面去努力的。蘋果官方為swift新搞了個網站swift.org,也放出來了Ubuntu Linux平臺的預編譯好的swift工具鏈的打包檔案以及Linux下的編譯指南。我今天寫這麼一部落格的目的就是為了介紹和推廣Swift語言在初學者或者低年級大學生群體中的運用。
2.Swift+Ubuntu環境配置
首先假定我們已經安裝好Ubuntu Linux作業系統了,這個系統安裝很簡單,網上很多的步驟教程,虛擬機器的話推薦用VirtualBox。Swift支援Ubuntu 14.04和15.10兩個髮型版,我這選擇15.10版本的包。
第一步:下載 Swift 2.2 工具鏈壓縮包,開啟終端,輸入命令新建目錄並下載
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>mkdir swift && cd swift; diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~/swift</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>wget <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">https:</span>/<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/swift.org/builds</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/ubuntu1510/swift</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.2</span>-<span class="hljs-constant" style="box-sizing: border-box;">SNAPSHOT</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>-b/swift-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.2</span>-<span class="hljs-constant" style="box-sizing: border-box;">SNAPSHOT</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>-b-ubuntu15.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>.tar.gz</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li></ul>
第二步:用tar命令解壓 Swift 2.2 工具鏈壓縮包到當前目錄,並配置環境變數
先解壓,再進入目錄,目錄下會有usr/bin和usr/lib等等子目錄:bash [email protected]:~/swift$ tar xvf swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10.tar.gz
[email protected]:~/swift$
cd swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10/
然後配置使用者級別的環境變數,編輯$HOME/.bashrc配置檔案
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~/swift/swift-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.2</span>-<span class="hljs-constant" style="box-sizing: border-box;">SNAPSHOT</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>-b-ubuntu15.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>gedit <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$HOME</span>/.bashrc</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li></ul>
上面命令會調出圖形介面文字編輯器GEdit來編輯這個配置檔案,在檔案的最後輸入如下配置行並儲存退出編輯器
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> SWIFT_HOME=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$HOME</span>/swift/swift-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.2</span>-SNAPSHOT-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span>-b-ubuntu15.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> PATH=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$SWIFT_HOME</span>/usr/bin:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$PATH</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> LD_LIBRARY_PATH=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$SWIFT_HOME</span>/usr/lib:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$LD_LIBRARY_PATH</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> LIBRARY_PATH=<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$SWIFT_HOME</span>/usr/lib:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$LIBRARY_PATH</span></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">3</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">4</span></li></ul>
這樣環境變數就配置OK啦。這個時候我們只需要關閉我們的Shell終端重新開啟終端就生效了。
3.Swift+Ubuntu初次體驗
搞過iOS開發的都知道,2014年6月Swift剛出世時就隨Xcode帶了Playground功能,可以邊寫邊看執行結果,辣麼在Ubuntu Linux下有沒有類似的呢,也有,只是沒那麼強大的IDE支援,我們一樣可以執行類似Pyhton指令碼解析器一樣的Swift解析器,同步輸入Swift程式碼來“解析”執行。這個命令就是swift,在上面的環境變數設定完後重開終端就可以直接使用了,如下所示。
<code class="hljs coffeescript has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">diveinedu<span class="hljs-property" style="box-sizing: border-box;">@diveinedu</span>-<span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">VirtualBox</span>:~$ swift Welcome to Swift version <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.2</span>-dev (LLVM <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">46</span>be9ff861, Clang <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>deb154edc, Swift <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">778</span>f82939c). Type :help <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> assistance. <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>> <span class="hljs-reserved" style="box-sizing: border-box;">let</span> hello = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"hello"</span>; <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">hello</span>: String = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"hello"</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>> <span class="hljs-reserved" style="box-sizing: border-box;">let</span> world = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"diveinedu"</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">world</span>: String = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"diveinedu"</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>> <span class="hljs-reserved" style="box-sizing: border-box;">let</span> space = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">" "</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">space</span>: String = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">" "</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">print</span>(hello+space+world); hello diveinedu <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>>hello. Available <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">completions</span>: append<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(c: Character)</span> -></span> Void append<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(x: UnicodeScalar)</span> -></span> Void appendContentsOf<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(newElements: S)</span> -></span> Void appendContentsOf<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(other: String)</span> -></span> Void <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">characters</span>: String.CharacterView <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">debugDescription</span>: String <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">endIndex</span>: Index <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">hashValue</span>: Int insert<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(newElement: Character, atIndex: Index)</span> -></span> Void insertContentsOf<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(newElements: S, at: Index)</span> -></span> Void <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">isEmpty</span>: Bool <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">lowercaseString</span>: String <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">nulTerminatedUTF8</span>: ContiguousArray<CodeUnit> removeAll<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">()</span> -></span> Void removeAll<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(keepCapacity: Bool)</span> -></span> Void removeAtIndex<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(i: Index)</span> -></span> Character removeRange<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(subRange: Range<Index>)</span> -></span> Void replaceRange<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(subRange: Range<Index>, <span class="hljs-reserved" style="box-sizing: border-box;">with</span>: C)</span> -></span> Void replaceRange<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(subRange: Range<Index>, <span class="hljs-reserved" style="box-sizing: border-box;">with</span>: String)</span> -></span> Void reserveCapacity<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(n: Int)</span> -></span> Void <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">startIndex</span>: Index <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">unicodeScalars</span>: String.UnicodeScalarView <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">uppercaseString</span>: String <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">utf16</span>: String.UTF16View <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">utf8</span>: String.UTF8View withCString<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(f: UnsafePointer<Int8> throws -> ResultUnsafePointer<Int8> throws -> Result)</span> -></span> Result withMutableCharacters<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(body: (inout String.CharacterView) -> R(inout String.CharacterView) -> R)</span> -></span> R write<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(other: String)</span> -></span> Void writeTo<span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-params" style="color: rgb(102, 0, 102); box-sizing: border-box;">(&target: Target)</span> -></span> Void <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>> hello.isEmpty <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">$R0</span>: Bool = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">3</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">4</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">5</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">6</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">7</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">8</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">9</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">10</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">11</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">12</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">13</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">14</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">15</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">16</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">17</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">18</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">19</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">20</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">21</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">22</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">23</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">24</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">25</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">26</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">27</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">28</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">29</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">30</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">31</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">32</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">33</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">34</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">35</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">36</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">37</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">38</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">39</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">40</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">41</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">42</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">43</span></li></ul>
在這個解析執行介面還有自動提示補全功能!簡直四國矣.上面第五行是輸入hello後再輸入一點.然後按tab鍵,一下就出來這麼多關於字串的方法,媽媽再也不擔心我在終端模式下不記得方法名了。
上面這特簡單的幾行程式碼還沒包含類和物件,下面看看在swift解析器中直接輸入類的定義和物件建立和簡單使用。
<code class="hljs coffeescript has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">diveinedu<span class="hljs-property" style="box-sizing: border-box;">@diveinedu</span>-<span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">VirtualBox</span>:~$ swift Welcome to Swift version <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.2</span>-dev (LLVM <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">46</span>be9ff861, Clang <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>deb154edc, Swift <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">778</span>f82939c). Type :help <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> assistance. <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>> struct Resolution { <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3.</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4.</span> } <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5.</span> <span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">class</span> <span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">VideoMode</span> {</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6.</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> resolution = Resolution() <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> interlaced = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8.</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> frameRate = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9.</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">name</span>: String? <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10.</span> func description() <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11.</span> { <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12.</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">print</span>(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"name:\(name) frameRate:\(frameRate)"</span>) <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13.</span> } <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14.</span> } <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span>> <span class="hljs-reserved" style="box-sizing: border-box;">let</span> mode = VideoMode() <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">mode</span>: VideoMode = { resolution = { width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> } interlaced = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span> frameRate = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> name = nil } <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>> mode.name = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"1080p HD"</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span>> mode.frameRate = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">30.0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span>> mode.description() <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">name</span>:Optional(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"1080p HD"</span>) <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">frameRate</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">30.0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span>></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">3</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">4</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">5</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">6</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">7</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">8</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">9</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">10</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">11</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">12</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">13</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">14</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">15</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">16</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">17</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">18</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">19</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">20</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">21</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">22</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">23</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">24</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">25</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">26</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">27</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">28</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">29</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">30</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">31</span></li></ul>
這些都只是在swift解析器中臨時性的執行一些程式碼,如果我們需要新建.swift格式檔案然後編譯成可執行二進位制檔案形式又要怎樣做呢,同樣很簡單,我們可以用swiftc這個命令來編譯。 我們可以新建一個目錄來存放swift程式碼檔案,然後編輯一個test.swift:
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>mkdir -p <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$HOME</span>/swift/swiftcode diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>cd <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$HOME</span>/swift/swiftcode diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~/swift/swiftcode</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>gedit test.swift</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">3</span></li></ul>
當開啟gedit文字編輯器後,輸入上面的類和物件建立以及方法呼叫的程式碼,列出在下面
<code class="hljs coffeescript has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">struct Resolution { <span class="hljs-reserved" style="box-sizing: border-box;">var</span> width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> } <span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">class</span> <span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">VideoMode</span> {</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> resolution = Resolution() <span class="hljs-reserved" style="box-sizing: border-box;">var</span> interlaced = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> frameRate = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.0</span> <span class="hljs-reserved" style="box-sizing: border-box;">var</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(0, 136, 0);">name</span>: String? func description() { <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">print</span>(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"name:\(name) frameRate:\(frameRate)"</span>) } } <span class="hljs-reserved" style="box-sizing: border-box;">let</span> mode = VideoMode() mode.name = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"1080p HD"</span> mode.frameRate = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">30.0</span> mode.description()</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">3</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">4</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">5</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">6</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">7</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">8</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">9</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">10</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">11</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">12</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">13</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">14</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">15</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">16</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">17</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">18</span></li></ul>
儲存後關閉編輯器,然後執行swiftc test.swift來編譯原始檔,會出現如下連結錯誤:
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~/swift/swiftcode</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>swiftc test.swift <unknown><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span> <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">error:</span> link command failed with exit code <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">127</span> (use -v to see invocation) diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~/swift/swiftcode</span>$</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">3</span></li></ul>
解決辦法是安裝編譯依賴clang libicu-dev,輸入下面命令回車(會詢問當前使用者密碼)bash [email protected]:~/swift/swiftcode$ sudo apt-get install
clang libicu-dev
安裝完成後再次執行編譯命令swiftc test.swift就順利編譯成功,再當前目錄下輸出test可執行檔案。
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~/swift/swiftcode</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>swiftc test.swift diveinedu<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@diveinedu</span>-<span class="hljs-constant" style="box-sizing: border-box;">VirtualBox</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:~/swift/swiftcode</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>./test <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">name:</span><span class="hljs-constant" style="box-sizing: border-box;">Optional</span>(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"1080p HD"</span>) <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">frameRate:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">30.0</span></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">1</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">2</span></li><li style="box-sizing: border-box; padding: 0px 5px;"><span style="font-size:18px;">3</span></li></ul>
而且執行ldd ./test檢視此二進位制檔案依賴的動態庫可知,它連結了libswiftCore,這是所有swift程式都會需要的。
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span style="font-size:18px;">[email protected]<span class="hljs-attribute" style="box-sizing: border-box;">-VirtualBox</span>:~/swift/swiftcode$ ldd <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>/test linux<span class="hljs-attribute" style="box-sizing: border-box;">-vdso</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007ffcef3f5000</span>) libswiftCore<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /home/diveinedu/swift/swift<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.2</span><span class="hljs-attribute" style="box-sizing: border-box;">-SNAPSHOT</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">01</span><span class="hljs-attribute" style="box-sizing: border-box;">-b</span><span class="hljs-attribute" style="box-sizing: border-box;">-ubuntu15</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.10</span>/usr/lib/swift/linux/libswiftCore<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd2f75000</span>) libstdc<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">++</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.6</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /usr/lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libstdc<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">++</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.6</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd2bdd000</span>) libm<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.6</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libm<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.6</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd28d5000</span>) libgcc_s<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libgcc_s<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd26be000</span>) libc<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.6</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libc<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.6</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd22f3000</span>) libpthread<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libpthread<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd20d5000</span>) libdl<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.2</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libdl<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.2</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd1ed1000</span>) libicuuc<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.55</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /usr/lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libicuuc<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.55</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd1b3c000</span>) libicui18n<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.55</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /usr/lib/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-linux</span><span class="hljs-attribute" style="box-sizing: border-box;">-gnu</span>/libicui18n<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.55</span> (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0x00007f1cd16d9000</span>) libbsd<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=></span> /lib/x86_64<span class="hljs-attribute" style="box