ubuntu18.04安装eigen算法库

156 篇文章 17 订阅
146 篇文章 19 订阅

eigin是一套用于进行线性代数,矩阵,以及数学计算的数学库,这一点它有点类似于openblas.

eigen还是点云库(PCL)的基础呢:

Ubuntu 下安装Eigen有两种方式,一种是“apt-get”方式,一种是源码安装方式,我们分别试一下:

1.apt-get安装预编译runtime库

终端窗口,输入:

sudo apt-get install libeigen3-dev

 测试用例:

#include <iostream>
#include <eigen3/Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
	MatrixXd m(2,2);
	m(0,0) = 3;
	m(1,0) = 2.5;
	m(0,1) = -1;
	m(1,1) = m(1,0) + m(0,1);
	std::cout << m << std::endl;
	return 0;
}

编译

g++ main.c -o main

执行:

 2.源码安装方式

关于eigen的官网:

http://eigen.tuxfamily.org/index.php?title=Main_Page

下载代码:

git clone https://gitlab.com/libeigen/eigen.git
或
wget -c https://gitlab.com/libeigen/eigen/-/archive/3.2.10/eigen-3.2.10.tar.bz2

编译:

compile-eigen/eigen-3.2.10
mkdir build
cd build
cmake ../
czl@czl-VirtualBox:~/compile-eigen/eigen-3.2.10/build$ cmake ../
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
abort: repository /home/czl/compile-eigen/eigen-3.2.10 not found!
abort: repository /home/czl/compile-eigen/eigen-3.2.10 not found!
-- Performing Test standard_math_library_linked_to_automatically
-- Performing Test standard_math_library_linked_to_automatically - Success
-- Standard libraries to link to explicitly: none
-- Performing Test COMPILER_SUPPORT_WERROR
-- Performing Test COMPILER_SUPPORT_WERROR - Success
-- Performing Test COMPILER_SUPPORT_pedantic
-- Performing Test COMPILER_SUPPORT_pedantic - Success
-- Performing Test COMPILER_SUPPORT_Wall
-- Performing Test COMPILER_SUPPORT_Wall - Success
-- Performing Test COMPILER_SUPPORT_Wextra
-- Performing Test COMPILER_SUPPORT_Wextra - Success
-- Performing Test COMPILER_SUPPORT_Wundef
-- Performing Test COMPILER_SUPPORT_Wundef - Success
-- Performing Test COMPILER_SUPPORT_Wcastalign
-- Performing Test COMPILER_SUPPORT_Wcastalign - Success
-- Performing Test COMPILER_SUPPORT_Wcharsubscripts
-- Performing Test COMPILER_SUPPORT_Wcharsubscripts - Success
-- Performing Test COMPILER_SUPPORT_Wnonvirtualdtor
-- Performing Test COMPILER_SUPPORT_Wnonvirtualdtor - Success
-- Performing Test COMPILER_SUPPORT_Wunusedlocaltypedefs
-- Performing Test COMPILER_SUPPORT_Wunusedlocaltypedefs - Success
-- Performing Test COMPILER_SUPPORT_Wpointerarith
-- Performing Test COMPILER_SUPPORT_Wpointerarith - Success
-- Performing Test COMPILER_SUPPORT_Wwritestrings
-- Performing Test COMPILER_SUPPORT_Wwritestrings - Success
-- Performing Test COMPILER_SUPPORT_Wformatsecurity
-- Performing Test COMPILER_SUPPORT_Wformatsecurity - Success
-- Performing Test COMPILER_SUPPORT_Wnopsabi
-- Performing Test COMPILER_SUPPORT_Wnopsabi - Success
-- Performing Test COMPILER_SUPPORT_Wnovariadicmacros
-- Performing Test COMPILER_SUPPORT_Wnovariadicmacros - Success
-- Performing Test COMPILER_SUPPORT_Wnolonglong
-- Performing Test COMPILER_SUPPORT_Wnolonglong - Success
-- Performing Test COMPILER_SUPPORT_fnochecknew
-- Performing Test COMPILER_SUPPORT_fnochecknew - Success
-- Performing Test COMPILER_SUPPORT_fnocommon
-- Performing Test COMPILER_SUPPORT_fnocommon - Success
-- Performing Test COMPILER_SUPPORT_fstrictaliasing
-- Performing Test COMPILER_SUPPORT_fstrictaliasing - Success
-- Performing Test COMPILER_SUPPORT_wd981
-- Performing Test COMPILER_SUPPORT_wd981 - Failed
-- Performing Test COMPILER_SUPPORT_wd2304
-- Performing Test COMPILER_SUPPORT_wd2304 - Failed
-- Performing Test COMPILER_SUPPORT_STRICTANSI
-- Performing Test COMPILER_SUPPORT_STRICTANSI - Failed
-- Performing Test COMPILER_SUPPORT_Qunusedarguments
-- Performing Test COMPILER_SUPPORT_Qunusedarguments - Failed
-- Performing Test COMPILER_SUPPORT_ansi
-- Performing Test COMPILER_SUPPORT_ansi - Success
-- Performing Test COMPILER_SUPPORT_OPENMP
-- Performing Test COMPILER_SUPPORT_OPENMP - Success
-- Found unsuitable Qt version "" from NOTFOUND
-- /home/czl/compile-eigen/eigen-3.2.10/build/test
-- Could NOT find CHOLMOD (missing: CHOLMOD_INCLUDES CHOLMOD_LIBRARIES) 
-- Could NOT find UMFPACK (missing: UMFPACK_INCLUDES UMFPACK_LIBRARIES) 
-- Could NOT find SUPERLU (missing: SUPERLU_INCLUDES SUPERLU_LIBRARIES) 
-- Could NOT find PASTIX (missing: PASTIX_INCLUDES PASTIX_LIBRARIES) 
-- Could NOT find SCOTCH (missing: SCOTCH_INCLUDES SCOTCH_LIBRARIES) 
-- Could NOT find METIS (missing: METIS_INCLUDES METIS_LIBRARIES) 
-- Could NOT find SPQR (missing: SPQR_INCLUDES SPQR_LIBRARIES) 
-- Found unsuitable Qt version "" from NOTFOUND
-- The Fortran compiler identification is GNU 7.5.0
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
-- Could NOT find GOOGLEHASH (missing: GOOGLEHASH_INCLUDES GOOGLEHASH_COMPILE) 
-- Could NOT find ADOLC (missing: ADOLC_INCLUDES ADOLC_LIBRARIES) 
-- Could NOT find MPFR (missing: MPFR_INCLUDES MPFR_LIBRARIES MPFR_VERSION_OK) (Required is at least version "2.3.0")
-- Found GMP: /usr/include/x86_64-linux-gnu  
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Could NOT find FFTW (missing: FFTW_INCLUDES FFTW_LIBRARIES) 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found GLUT: /usr/lib/x86_64-linux-gnu/libglut.so  
-- Found unsuitable Qt version "" from NOTFOUND
-- Qt4 not found, so disabling the mandelbrot and opengl demos
-- Could NOT find CHOLMOD (missing: CHOLMOD_INCLUDES CHOLMOD_LIBRARIES) 
-- Could NOT find UMFPACK (missing: UMFPACK_INCLUDES UMFPACK_LIBRARIES) 
-- Could NOT find SUPERLU (missing: SUPERLU_INCLUDES SUPERLU_LIBRARIES) 
-- Could NOT find PASTIX (missing: PASTIX_INCLUDES PASTIX_LIBRARIES) 
-- Could NOT find SCOTCH (missing: SCOTCH_INCLUDES SCOTCH_LIBRARIES) 
-- Could NOT find METIS (missing: METIS_INCLUDES METIS_LIBRARIES) 
-- ************************************************************
-- ***    Eigen's unit tests configuration summary          ***
-- ************************************************************
-- 
-- Build type:        Release
-- Build site:        czl-VirtualBox
-- Build string:      linux-5.4.0-80-generic-_-7.5.0-sse2-64bit
-- Enabled backends:  
-- Disabled backends: Cholmod,  UmfPack,  SuperLU,  PaStiX,  METIS,  Qt4 support,  GoogleHash,  Adolc,  MPFR C++,  fftw,  OpenGL, 
-- Default order:     Column-major
-- Maximal matrix/vector size: 320
-- SSE2:              Using architecture defaults
-- SSE3:              Using architecture defaults
-- SSSE3:             Using architecture defaults
-- SSE4.1:            Using architecture defaults
-- SSE4.2:            Using architecture defaults
-- Altivec:           Using architecture defaults
-- ARM NEON:          Using architecture defaults
-- 
CXX:               /usr/bin/c++
 CXX_VERSION:       c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
 CXX_FLAGS:          -fexceptions -pedantic -Wall -Wextra -Wundef -Wcast-align -Wchar-subscripts -Wnon-virtual-dtor -Wunused-local-typedefs -Wpointer-arith -Wwrite-strings -Wformat-security -Wno-psabi -Wno-variadic-macros -Wno-long-long -fno-check-new -fno-common -fstrict-aliasing -ansi  -g2
 Sparse lib flags:   

-- ************************************************************
-- 
-- Configured Eigen 3.2.10
-- 
-- Some things you can do now:
-- --------------+--------------------------------------------------------------
-- Command       |   Description
-- --------------+--------------------------------------------------------------
-- make install  | Install Eigen. Headers will be installed to:
--               |     <CMAKE_INSTALL_PREFIX>/<INCLUDE_INSTALL_DIR>
--               |   Using the following values:
--               |     CMAKE_INSTALL_PREFIX: /usr/local
--               |     INCLUDE_INSTALL_DIR:  include/eigen3
--               |   Change the install location of Eigen headers using:
--               |     cmake . -DCMAKE_INSTALL_PREFIX=yourprefix
--               |   Or:
--               |     cmake . -DINCLUDE_INSTALL_DIR=yourdir
-- make doc      | Generate the API documentation, requires Doxygen & LaTeX
-- make check    | Build and run the unit-tests. Read this page:
--               |   http://eigen.tuxfamily.org/index.php?title=Tests
-- make blas     | Build BLAS library (not the same thing as Eigen)
-- --------------+--------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/czl/compile-eigen/eigen-3.2.10/build
czl@czl-VirtualBox:~/compile-eigen/eigen-3.2.10/build$ 

编译安装:

sudo make install

编译blas:

make blas


结束!

  • 8
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

papaofdoudou

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值