来自Linux Mint的Eigen3 17.3 repo,SparseMatrix未命名为

时间:2016-07-20 16:49:20

标签: c++ linux cmake eigen

我正在尝试在我的项目中使用Eigen3,当我尝试使用CMake构建时,我收到此错误

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

我正在使用Linux Mint 17.3。我有两个eigen2和eigen3库,我很确定CMake正在选择eigen3(特别是考虑到我上面发布的错误消息)。我使用命令安装了eigen3 sudo apt-get install libeigen3-dev。 当我运行apt-cache show libeigen3-dev时,我得到了

Package: libeigen3-dev
Priority: extra
Section: universe/libdevel
Installed-Size: 5130
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
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
Homepage: http://eigen.tuxfamily.org
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 9m

这是一个最小的代码段:

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

使用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;

1 个答案:

答案 0 :(得分:1)

您可以使用正确的inlcude解决问题。第一个定义SparseMatrix来纠正您的第一条错误消息。第二个使用正确的路径来纠正您的第二个错误消息。

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