Compile and use the Lapack package in linux

Source: Internet
Author: User
Tags lapack gfortran
Compile and use the Lapack package in linux-Linux general technology-Linux programming and kernel information. For details, see the following. 1. Download the source code of the latest version from netlab
Http://www.netlib.org/lapack/lapack-3.1.0.tgz

2. Extract the source code
Tar-zxf lapack-3.1.0.tgz

3. Edit the make. inc file and set system-related compilation parameters.
PLAT: Set the suffix of the generated library function, such as SUN and LINUX. Of course, you can also leave it unspecified;
FORTRAN: Set the compiler, such as g77, gfortran, ifort, and g95;
OPT: Set the compilation options according to the specific compiler and optimization requirements;
LOADER: Set it like FORTRAN;

4. Edit Makefile
Find lib: option. Then set the library function to be compiled as follows:
# Lib: lapacklib tmglib
Lib: blaslib lapacklib tmglib
The blas library is not compiled by default.

5. Compile and test Lapack.
Enter make in the root directory of the source code and press Enter. Then the make program will automatically compile and test.

6. Use of the Lapack Function
If compilation and testing are successful, three lapack. a, blas. a, and tmglib. a files will be generated under the source code root directory. Lapack. a And blas. a are the library functions we need. They can be used in two ways:

A) cp lapack. a liblapack. a, cp blas. a libblas. a and copy it to the LD_LIBRARY_PATH directory, or add the directory to the LD_LIBRARY_PATH environment variable, or add the "-L lapack directory/" option during compilation. Add the compile option-llapack-lblas during compilation.

B) Compile lapack. a And blas. a together with the code to be compiled. For example, the main. f90 compiler is gfortran. Gfortran main. f90 lapack. a blas..

You can also use Lapack as a dynamically linked library file. Of course, in linux, you can also directly install compiled files such as redhat and suse to install rpm files. In ubuntu and debian systems, install deb files. However, it is better to compile the library functions based on your own environment, so the speed will be faster. I have done experiments in ubuntu. Generally, the speed relationship is: Self-compiled library functions> matlab functions.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.