第1章 安裝

原文連接  https://erlang.mk/guide/installation.htmlhtml

 

Chapter 1. Installation

 

1.1. On Unix

Erlang.mk requires GNU Make to be installed. While it will currently work with GNU Make 3.81, support for this version is deprecated and will be removed in 2017. We recommend GNU Make 4.1 or later.git

Git and Erlang/OTP must also be installed.github

Some functionality requires that Autoconf 2.59 or later be installed, in order to compile Erlang/OTP. Erlang/OTP may have further requirements depending on your needs.shell

Some packages may require additional libraries.windows

1.1.1. Linux

The commands to install packages vary between distributions:bash

Arch Linux. less

$ pacman -S erlang git make

 

1.1.2. FreeBSD

FreeBSD comes with binary and source packages:編輯器

Install binary packages. ide

$ pkg install erlang git gmake

 

On FreeBSD the make command is BSD Make. Use gmake instead.post

1.1.3. OS X and macOS

While Apple distributes their own GNU Make, their version is very old and plagued with numerous bugs. It is recommended to install a more recent version from either Homebrew or MacPorts:

Homebrew. 

$ brew install erlang git make

 

Homebrew installs GNU Make as gmake. The make command is the one provided by Apple.

MacPorts. 

$ sudo port install erlang git gmake

 

1.2. On Windows

1.2. 在Windows上

 

Erlang.mk can be used on Windows inside an MSYS2 environment. Cygwin, MSYS (the original) and native Windows (both Batch and PowerShell) are currently not supported.

Erlang.mk能夠在安裝有MSYS2環境的Windows上使用,暫時不支持在Cygwin,原始的MSYS和windows本地(包括批處理和PowerShell)中直接使用。

 

Note

注意

 

Erlang.mk expects Unix line breaks in most of the files (LF instead of CRLF). Make sure to configure your text editor adequately.

Erlang.mk指望大多數文件是Unix換行符(LF而不是CRLF),請確保文本編輯器的配置是Unix換行符。

 

The rest of this section details how to setup Erlang/OTP and MSYS2 in order to use Erlang.mk.

本節其他部分將詳細介紹如何設置 Erlang/OTP 和 MSYS2,以便在Windows下使用Erlang.mk。

 

1.2.1. Installing Erlang/OTP

1.2.1. 安裝Erlang/OTP

 

Erlang.mk requires Erlang/OTP to be installed. The OTP team provides binaries of Erlang/OTP for all major and minor releases, available from the official download page. It is recommended that you use the 64-bit installer unless technically impossible. Please follow the instructions from the installer to complete the installation.

使用Erlang.mk必須安裝好Erlang/OTP。OTP團隊提供全部主板本和次版本的Erlang/OTP二進制文件,可從官方下載頁面得到。推薦使用64位安裝程序,除非技術上不可行。請按照安裝程序的指令完成安裝。

 

The OTP team also provides a short guide to installing Erlang/OTP on Windows if you need additional references.

若是你須要額外的參考資料,OTP團隊也提供了Windows安裝Erlang/OTP的簡要指南。

 

You can install Erlang/OTP silently using the /S switch on the command line:

你能夠在命令行上使用 /S 開關,靜默安裝Erlang/OTP:

C:\Users\essen\Downloads> otp_win64_18.0.exe /S

 

1.2.2. Installing MSYS2

1.2.2. 安裝MSYS2

 

The only supported environment on Windows is MSYS2. MSYS2 is a lightweight Unix-like environment for Windows that comes with the Arch Linux package manager, pacman.

Erlang.mk在Windows上惟一受到支持的環境是MSYS2。MSYS2是Arch Linux軟件包管理器  pacman 附帶的一個輕量級類Unix環境。

 

The MSYS2 project provides a one click installer and instructions to set things up post-installation.

MSYS2項目提供了一個單擊安裝程序,並提供指令來設置安裝後的內容。

 

It is currently not possible to use the installer silently. Thankfully, the MSYS2 project provides an archive that can be used in lieu of the installer. The archive however requires 7zip to decompress it.

MSYS2目前沒法使用靜默安裝,值得慶幸的是,MSYS2項目提供了一個可用來代替安裝程序的壓縮包,這個壓縮包須要使用 7zip 來解壓。

 

First, download the MSYS2 base archive and extract it under C:\. Assuming you downloaded the archive as msys2.tar.xz and put it in C:\, you can use the following commands to extract it:

首先,下載 MSYS2基礎壓縮包 並解壓到 C:\ 目錄。假設你下載了壓縮包爲 msys2.tar.xz 並將其放在了C:\,你可使用如下命令來提取它:

C:\> 7z x msys2.tar.xz
C:\> 7z x msys2.tar > NUL

 

Then you can run the two commands needed to perform the post-installation setup:

而後你能夠運行執行安裝後設置所需的兩個命令:

C:\> C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -Sy bash pacman pacman-mirrors msys2-runtime"
C:\> C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syu"

 

1.2.3. Installing the required MSYS2 packages

1.2.3. 安裝所需的MSYS2軟件包

 

After following these instructions, you can install GNU Make, Git and any other required softwares. From an MSYS2 shell, you can call pacman directly:

按照這些說明,你能夠安裝GNU Make,Git和其餘所需的軟件。在MSYS2 shell下,你能夠直接調用 pacman :

$ pacman -S git make

 

You can use pacman -Ss to search packages. For example, to find all packages related to GCC:

你可使用 pacman -Ss 來搜索軟件包。例如,要查找與GCC相關的全部軟件包:

$ pacman -Ss gcc

 

If you are going to compile C/C++ code, you will need to install this package, as Erlang.mk cannot use the normal "gcc" package:

若是你要編譯 C/C++ 代碼,你須要安裝這個包,由於Erlang.mk不能使用標準「gcc」包:

$ pacman -S mingw-w64-x86_64-gcc

 

You can also run commands under the MSYS2 environment from the Windows command line or batch files. This command will install GNU Make and Git:

你也能夠從Windows命令行或批處理文件中讓命令運行在MSYS2環境下。 這個命令將安裝GNU Make和Git:

C:\> C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S git make"

 

You can use similar bash commands if you need to run programs inside the MSYS2 environment from a batch file.

若是你須要在批處理文件中讓程序運行在MSYS2環境下,則可使用相似的 bash 命令。

 

1.2.4. Gotchas

1.2.4. 陷阱

 

While most of the basic functionality will just work, there are still some issues. Erlang.mk needs to be fixed to pass the right paths when running Erlang scripts. We are working on it. Erlang.mk is fully tested on both Linux and Windows, but is lacking tests in the areas not yet covered by this guide, so expect bugs to be fixed as more tests are added.

雖然大部分基本功能都能正常工做,但仍存在一些問題。在運行Erlang腳本時,須要修復Erlang.mk來傳遞正確的路徑,咱們正在解決這個問題。Erlang.mk在Linux和Windows上都獲得了充分的測試,可是在本指南還未涵蓋的領域缺乏測試,在添加了更多的測試後,但願bug可以被修復。

相關文章
相關標籤/搜索