官术网_书友最值得收藏!

Obtaining prebuilt packages

To ease the task of installing the software on your system, LLVM contributors prepare prebuilt packages with the compiled binaries for a specific platform, as opposed to the requirement that you compile the package yourself. Compiling any piece of software can be tricky in some circumstances; it might require some time and should only be necessary if you are using a different platform or actively working on project development. Therefore, if you want a quick way to start with LLVM, explore the available prebuilt packages. In this book, however, we will encourage you to directly hack in to the LLVM source tree. You should be prepared to be able to compile LLVM from source trees yourself.

There are two general ways to obtain prebuilt packages for LLVM; you can obtain packages via distributed binaries in the official website or by third-party GNU/Linux distributions and Windows installers.

Obtaining the official prebuilt binaries

For version 3.4, the following prebuilt packages can be downloaded from the official LLVM website:

To view all the options for a different version, access http://www.llvm.org/releases/download.html and check the Pre-built Binaries section relative to the version you want to download. For instance, to download and perform a system-wide installation of LLVM on Ubuntu 13.10, we obtain the file's URL at the site and use the following commands:

$ sudo mkdir -p /usr/local; cd /usr/local
$ sudo wget http://llvm.org/releases/3.4/clang+llvm-3.4-x86_64-linux-gnu-ubuntu-13.10.tar.xz
$ sudo tar xvf clang+llvm-3.4-x86_64-linux-gnu-ubuntu-13.10.tar.xz
$ sudo mv clang+llvm-3.4-x86_64-linux-gnu-ubuntu-13.10 llvm-3.4
$ export PATH="$PATH:/usr/local/llvm-3.4/bin"

LLVM and Clang are now ready to be used. Remember that you need to permanently update your system's PATH environment variable, since the update we did in the last line is only valid for the current shell session. You can test the installation by executing Clang with a simple command, which prints the Clang version you just installed:

$ clang –v

If you have a problem when running Clang, try to run the binary directly from where it was installed to make sure that you are not running into a misconfigured PATH variable issue. If it still doesn't work, you might have downloaded a prebuilt binary for an incompatible system. Remember that, when compiled, the binaries link against dynamic libraries with specific versions. A link error while running the application is a clear symptom of the use of a binary compiled to a system that is incompatible with yours.

Tip

In Linux, for example, a link error can be reported by printing the name of the binary and the name of the dynamic library that failed to load, followed by an error message. Pay attention when the name of a dynamic library is printed on the screen. It is a clear sign that the system dynamic linker and loader failed to load this library because this program was not built for a compatible system.

To install prebuilt packages in other systems, the same steps can be followed, except for Windows. The prebuilt package for Windows comes with an easy-to-use installer that unpacks the LLVM tree structure in a subfolder of your Program Files folder. The installer also comes with the option to automatically update your PATH environment variable to be able to use Clang executables from within any command prompt window.

Using package managers

Package manager applications are available for a variety of systems and are also an easy way to obtain and install LLVM/Clang binaries. For most users, this is usually the recommended way to install LLVM and Clang, since it automatically handles dependency issues and ensures that your system is compatible with the installed binaries.

For example, in Ubuntu (10.04 and later), you should use the following command:

$ sudo apt-get install llvm clang

In Fedora 18, the command line used is similar but the package manager is different:

$ sudo yum install llvm clang

Staying updated with snapshot packages

Packages can also be built from nightly source code snapshots, containing the latest commits from the LLVM subversion repository. The snapshots are useful to LLVM developers and users who wish to test the early versions or to third-party users who are interested in keeping their local projects up-to-date with mainline development.

Linux

Debian and Ubuntu Linux (i386 and amd64) repositories are available for you to download the daily compiled snapshots from the LLVM subversion repositories. You can check for more details at http://llvm.org/apt.

For example, to install the daily releases of LLVM and Clang on Ubuntu 13.10, use the following sequence of commands:

$ sudo echo "deb http://llvm.org/apt/raring/ llvm-toolchain-raring main" >> /etc/apt/sources.list
$ wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add –
$ sudo apt-get update
$ sudo apt-get install clang-3.5 llvm-3.5

Windows

Windows installers of specific LLVM/Clang snapshots are available for download at http://llvm.org/builds/ in the Windows snapshot builds section. The final LLVM/Clang tools are installed by default in C:\Program Files\LLVM\bin (this location may change depending on the release). Note that there is a separate Clang driver that mimics Visual C++ cl.exe named clang-cl.exe. If you intend to use the classic GCC compatible driver, use clang.exe.

Tip

Note that snapshots are not stable releases and might be highly experimental.

主站蜘蛛池模板: 大名县| 仁寿县| 乌兰察布市| 海南省| 共和县| 同江市| 仁布县| 灵台县| 秀山| 蓬安县| 西贡区| 武义县| 汤原县| 日喀则市| 兴业县| 宾川县| 巴东县| 两当县| 临清市| 崇左市| 庆安县| 玉龙| 石棉县| 蒲江县| 额济纳旗| 宜兰市| 湟中县| 前郭尔| 高邮市| 清水县| 清苑县| 德庆县| 林周县| 八宿县| 南宫市| 焉耆| 诏安县| 山西省| 安吉县| 台中市| 平度市|