2016-07-20 34 views
0

我想在我的項目中使用Eigen3,當我嘗試使用CMake的構建,使Eigen3從Linux Mint的17.3回購,稀疏矩陣未命名

/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(尤其是考慮到我在上面發佈的錯誤消息)。我使用命令 sudo apt-get install libeigen3-dev安裝了eigen3。 當我運行apt-cache show libeigen3-dev我得到

Package: libeigen3-dev 
Priority: extra 
Section: universe/libdevel 
Installed-Size: 5130 
Maintainer: Ubuntu Developers <[email protected]> 
Original-Maintainer: Debian Science Maintainers <[email protected]> 
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; 
+0

官方版本怎麼樣? – kangshiyin

+0

我測試了mercurial repo的官方版本,並且得到了同樣的錯誤。 – BlazePascal

+0

舊版本如3.2.9如何?無論如何,它是'不支持的' – kangshiyin

回答

1

您的問題可以用正確的inlcude s內解決。第一個定義了SparseMatrix,它糾正了你的第一個錯誤信息。第二個使用正確的路徑來糾正你的第二個錯誤信息。

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

這仍然給出了我最初列出的錯誤。 'SparseMatrix不會命名一個類型......' – BlazePascal

+0

你如何配置你的代碼?什麼是編譯選項? – kangshiyin

+0

'g ++ -std = C++ 11 -I/usr/local/include/eigen3 hello.cpp -o hello' – BlazePascal