Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Eigen don't need to link .lib or dll?

Tags:

eigen

Recently, I compiled Eigen3 and use it to do some linear algebra task at Windows.

But I wonder why Eigen3 doesn't need to link additional lib or DLL (I just need to include its header)

Does Eigen do all calculating at compile time? Or do I miss understanding something?

If so, what is the category name of this kind library

like image 625
tirth Avatar asked Dec 04 '12 14:12

tirth


1 Answers

Like all C++ template libraries, Eigen is completely contained in the header file and inserted in the source file everytime. So it does not contain on any cpp files, which would be compiled to a dll.

The distinction between dll/lib and header occurs when the classes are declared in the header and implemented in a cpp file. Then the implementation part is always the same and can be loaded from a dll.

However, in a template library, the classes are not finished, since they depend on the template parameters you pass to them. e.g. if you write Matrix<float, 17, 19>, you create a new complete class with a completely new implementation, which could not be loaded from a dll.

This also makes c++ programs that uses a lot of templates (like many different fixed size matrices), very big.

like image 104
BeniBela Avatar answered Oct 22 '22 23:10

BeniBela