How to Install GMP in Ubuntu

来源:互联网 发布:汇通天下g7怎么样知乎 编辑:程序博客网 时间:2024/05/16 13:00

转载自:http://www.ehow.com/how_8328719_install-gmp-ubuntu.html,Allen Bethea

Although Ubuntu ships with its own implementation of the GNU Multiple Precision Arithmetic Library already installed, if you need the latest and most complete version of the software, you will need to download, compile and install it yourself. The compressed GMP archive contains all the source code and configuration utilities you need as well as a suite of demonstration programs you can build to test the libraries.

  • Download the latest stable version of GMP's source code from the developer's website using the link found in Resources.

  • Launch a Terminal session, extract the GMP archive's contents into the folder you downloaded it to and then set the extracted source code folder as your active directory. For example, if you downloaded the file "gmp-6.0.0a.tar.lz" from the GMP website, open the extracted "gmp-6.0.0" folder.

  • Build the makefile for GMP. The configure script will examine your system to see that all of GMP's hardware and software dependencies are met and then build the makefile that contains the compiler commands necessary to create binary library files. For example, if you are working with a new install of Ubuntu, the configure script will let you know that you need to install the M4 macro processor first. To build the makefile, type the following command at the command prompt and press "Enter:"

    ./configure

    If you need to install M4 or any other dependency, run the "./configure" command again.

  • Build GMP's binary library files with the Make command. Make compiles and links all the individual components of the GMP library. Type "make" at the command prompt and then press "Enter." Compilation may take awhile to complete. For example, GMP version 6.0 consists of 2581 individual files that must be pre-processes, compiled, assembled and linked.

  • Install GMP's libraries on your system. While you can compile GMP as a normal user, you will need root permission and the sudo command to install the libraries to your system. Type the following command at the terminal prompt, press "Enter," type your password and then press "Enter" to install GMP.

    sudo make install

    GMP's library files will be stored in the /usr/local/lib folder. The GMP library files that Ubuntu installs by default, however, remain /usr/lib/i386-linux-gnu/ on 32-bit systems or usr/lib/x86_64-linux-gnu/ on 64-bit systems. If a program you use needs the version of GMP you compiled, you will have to configure it to look for the libraries in the /usr/local/lib directory instead.

Tips & Warnings

  • Use the Make command to uninstall GMP if you don't want it available system-wide or you no longer need the libraries at all. GMP's makefile contains all the information needed to cleanly remove its files from your root directory. To uninstall GMP, move to the directory you compiled GMP within and then run the following command at the terminal prompt:
  • sudo make uninstall
  • Information in this article applies to Ubuntu 14.04 Trusty Tahr and GMP version 6.0.0. Procedures may vary with other versions of Ubuntu or GMP. The GMP package includes a "Check" utility that examines generated code for errors caused by your system's compiler. Before you run "make install" and add the GMP libraries to your production machine, run the following command at the terminal prompt:
  • make check

  • If no errors are reported, you can install GMP.

0 0
原创粉丝点击