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

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.

主站蜘蛛池模板: 河曲县| 临泉县| 宜章县| 金沙县| 温州市| 五峰| 马山县| 巴林右旗| 思茅市| 乡城县| 遂川县| 汉阴县| 类乌齐县| 班戈县| 红安县| 静乐县| 琼结县| 潢川县| 深泽县| 托克托县| 博客| 石泉县| 法库县| 米林县| 株洲市| 上饶县| 湘潭县| 南阳市| 天津市| 云阳县| 延津县| 防城港市| 盘锦市| 陆川县| 黄大仙区| 南阳市| 石城县| 竹溪县| 正镶白旗| 化德县| 鄂州市|