用CXX_FLAGS构建Eigen3

时间:2017-06-06 10:19:56

标签: c++11 tensorflow opencl eigen intel-mkl

我试图使用CMake构建Eigen3,如安装中所述:

root@60e449767588:/opt/tr/src/eigen/build_dir$ ../../cmake-3.8.1/bin/cmake  -DCMAKE_BUILD_TYPE=Release --build ..

这是输出:

-- Standard libraries to link to explicitly: none
-- Found unsuitable Qt version "" from NOTFOUND
-- 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 SUPERLU_VERSION_OK) 
-- 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
-- Boost version: 1.64.0
-- 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")
-- Could NOT find GMP (missing:  GMP_INCLUDES GMP_LIBRARIES) 
-- Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE) 
-- Could NOT find FFTW (missing:  FFTW_INCLUDES FFTW_LIBRARIES) 
-- Could NOT find OpenGL (missing:  OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR) 
-- Could NOT find GLUT (missing:  GLUT_glut_LIBRARY GLUT_INCLUDE_DIR) 
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing:  CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.0")
-- 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 SUPERLU_VERSION_OK) 
-- 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:        60e449767588
-- Build string:      linux-4.4.0-78-generic-_-4.9.2-sse2-64bit
-- Enabled backends:  Boost.Multiprecision, 
-- Disabled backends: Cholmod,  UmfPack,  SuperLU,  PaStiX,  METIS,  SPQR,  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
-- AVX:               Using architecture defaults
-- FMA:               Using architecture defaults
-- AVX512:            Using architecture defaults
-- Altivec:           Using architecture defaults
-- VSX:               Using architecture defaults
-- ARM NEON:          Using architecture defaults
-- ARMv8 NEON:        Using architecture defaults
-- S390X ZVECTOR:     Using architecture defaults
-- C++11:             OFF
-- SYCL:              OFF
-- CUDA:              OFF
-- 
CXX:               /usr/bin/c++
 CXX_VERSION:       c++ (Debian 4.9.2-10) 4.9.2
 CXX_FLAGS:         -O3 -DNDEBUG -fPIC -DEIGEN_USE_MKL_ALL -DMKL_ILP64 -fopenmp -m64 -v -pedantic -Wall -Wextra -Wundef -Wcast-align -Wchar-subscripts -Wnon-virtual-dtor -Wunused-local-typedefs -Wpointer-arith -Wwrite-strings -Wformat-security -Wlogical-op -Wdouble-promotion -Wno-psabi -Wno-variadic-macros -Wno-long-long -fno-check-new -fno-common -fstrict-aliasing -ansi
 Sparse lib flags:   

-- ************************************************************
-- 
-- Configured Eigen 3.3.3
-- 
-- 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)
-- make uninstall| Removes files installed by make install
-- --------------+--------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/tr/src/eigen/build_dir

我的问题是:

  1. 如何删除CXX_FLAGS的默认值?

  2. 如何指定我希望使用C ++ 11甚至14?

  3. 如何指定我希望使用SYCL?

  4. 谢谢!

2 个答案:

答案 0 :(得分:3)

根据我的评论中的建议,Eigen是一个仅限标题的库(没有源文件),您不需要构建它。只需在您想要使用Eigen的地方包含相关标题即可。您可以将头文件(使用简单的cp)复制到适合您的任何地方。

请参阅 Getting Started 手册:

  

为了使用Eigen,你只需要下载并提取Eigen   源代码(有关下载说明,请参阅wiki)。事实上,   Eigen子目录中的头文件是唯一需要的文件   使用Eigen编译程序。头文件对所有人来说都是一样的   平台。没有必要使用CMake或安装任何东西。

Eigen wiki 提及:

  

我们使用CMake构建系统,但仅用于构建文档和   单元测试,以及自动化安装。如果你只是想使用   Eigen,您可以立即使用头文件。没有二进制文件   要链接到的库,没有配置的头文件。 Eigen是纯粹的   标题中定义的模板库。

因此,如果您对构建单元测试或文档不感兴趣,则不需要cmake

结论:您必须在使用Eigen的项目中指定编译器标志(CXX_FLAGS,...)。

答案 1 :(得分:2)

根据@ m7913d的答案,Eigen是一个仅限标题的库,因此您可以按照标准说明进行操作。

对于3,我使用ComputeCpp创建了使用EIG和SYCL的简短指南,该指南解释了如何使用张量操作创建一个简单的应用程序。 https://www.codeplay.com/products/computesuite/computecpp/guides/eigen