I'm making use of Eigen library which promises vectorization of matrix operations. I don't know how to use the files given in Eigen and write a makefile. The source files which make use of Eigen include files as listed below, these are not even header files (They are just some text files)-
<Eigen/Core>
<Eigen/Dense>
<Eigen/Eigen>
and so on. On Eigen's webpage, it's mentioned that, in order to use its functions I don't have to build the project, then how can I include these files in my makefile to build my project. My example main.c file looks like this. Can anyone show me how to write a 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!
According to Eigen's website, this is a header-only library.
This means there is nothing to compile or link it to. Instead, as long as you have the header files in a standard location (/usr/local/include
on *nix/Mac), then all you have to do is add that location to your preprocessor build step.
Assuming that you are running *nix/Mac, and assuming that you have everything installed to the default locations (e.g. #include <Eigen/Core>
references the file /usr/local/include/Eigen/Core
), then a SUPER simple makefile would look like this:
main: main.cpp
g++ -I /usr/local/include main.cpp -o main
Which says, in English:
main
depends on main.cpp
main
, use g++
to
main.cpp
, main
, /usr/local/include
for any headers it doesn't know aboutNOTE: there is a TAB in front of the g++
line, NOT four spaces.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With