How to write a makefile for a C ++ project that uses Eigen, a C ++ template library for linear algebra?

I use the Eigen library, which promises vectorization of matrix operations. I do not know how to use the files specified in Eigen and write a make file. The source files that Eigen uses include the files listed below, these are not even header files (these are just some text files) -

<Eigen/Core>
<Eigen/Dense>
<Eigen/Eigen>

etc. On his own web page, he mentioned that in order to use my functions I do not need to build a project, how can I include these files in my make file to create my project. My main.c example file looks like this. Can someone show me how to write makefile makefile for this file -

#include <Eigen/Core>

// import most common Eigen types 
USING_PART_OF_NAMESPACE_EIGEN

int main(int, char *[])
{
  Matrix3f m3;
  m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  Matrix4f m4 = Matrix4f::Identity();
  Vector4i v4(1, 2, 3, 4);

  std::cout << "m3\n" << m3 << "\nm4:\n"
    << m4 << "\nv4:\n" << v4 << std::endl;
}

Help!

+3
4

Eigen website, .

, . , (/usr/local/include on * nix/Mac), , , .

, * nix/Mac , (, #include <Eigen/Core> /usr/local/include/Eigen/Core), make SUPER :

main: main.cpp
    g++ -I /usr/local/include main.cpp -o main

-:

  • main main.cpp
  • main, g++
    • compile main.cpp,
    • main,
    • /usr/local/include ,

: g++ TAB, .

, .

+6

.

g++ -I /path/to/eigen2/ my_program.cpp -o my_program 

There is no library to link to. 

, () include Makefile.

+1

. Eigen , , - . , , , , .

Eigen .

Eigen , , - . include, g++, ...

g++ -I /path/to/eigen2/ source_file -o output_file
+1

If you need some fortran library, here is the command I use

g ++ source.cpp -o output -I /../ include -L /../ lib -L /../ lib64 -lcholmod -lmetis -lamd -lcamd -lccolamd -lcolamd -llapack -lgfortran -lblas

I am replacing the actual path ..

0
source

Source: https://habr.com/ru/post/1755298/


All Articles