Steve.Q Steve.Q - 1 year ago 95
Linux Question

Eigen3 from Linux Mint 17.3 repo, SparseMatrix not named

I am trying to use Eigen3 in my project and I get this error when I try to build using CMake and make

/usr/include/eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h:246:11: error: ‘SparseMatrix’ does not name a type
typedef SparseMatrix<Scalar, 0, StorageIndex> ReturnType;

I am using Linux Mint 17.3. I have both the eigen2 and eigen3 libraries and I'm pretty sure the CMake is picking eigen3 (especially given the error message I posted above). I installed eigen3 using the command
sudo apt-get install libeigen3-dev
When I run
apt-cache show libeigen3-dev
I get

Package: libeigen3-dev
Priority: extra
Section: universe/libdevel
Installed-Size: 5130
Maintainer: Ubuntu Developers <>
Original-Maintainer: Debian Science Maintainers <>
Architecture: all
Source: eigen3
Version: 3.3~beta1-2
Depends: pkg-config
Suggests: libeigen3-doc, libmrpt-dev
Filename: pool/universe/e/eigen3/libeigen3-dev_3.3~beta1-2_all.deb
Size: 662650
MD5sum: bad08ef7b1d166c5bc9903e510a9fb68
SHA1: ef35745fcd047f1a1f18834e02ccef1476d7407c
SHA256: 5c73d97dca2d950ce51bde451deed4b6508b2f6cca9b9b6563218591e029f17b
Description-en: lightweight C++ template library for linear algebra
Eigen 3 is a lightweight C++ template library for vector and matrix math,
a.k.a. linear algebra.
Unlike most other linear algebra libraries, Eigen 3 focuses on the simple
mathematical needs of applications: games and other OpenGL apps, spreadsheets
and other office apps, etc. Eigen 3 is dedicated to providing optimal speed
with GCC. A lot of improvements since 2-nd version of Eigen.
Description-md5: 71025bd67be9e83075fd5a0e7ab822a2
Origin: Ubuntu
Supported: 9m

Here's a minimal code snippet:

#include <unsupported/Eigen/KroneckerProduct>
int main() {
return 0;

compiling with
g++ -std=c++11 -I /usr/local/include/eigen3 hello.cpp -o hello

In file included from /usr/local/include/eigen3/unsupported/Eigen/KroneckerProduct:30:0,
from hello.cpp:4:
/usr/local/include/eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h:246:11: error: ‘SparseMatrix’ does not name a type
typedef SparseMatrix<Scalar, 0, StorageIndex> ReturnType;

Answer Source

You problem can be solved with correct inlcudes. The first one defines SparseMatrix which corrects your first error message. The second one uses proper path which corrects your second error message.

#include <Eigen/Sparse>
#include <unsupported/Eigen/KroneckerProduct>
int main() {
    return 0;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download