Including Eigen

不问归期 提交于 2020-01-16 08:38:12

问题


I've included the Eigen headers in a C++ project in Eclipse. When I try to build I get this error:

Symbol 'Eigen' could not be resolved    Semantic Error

From what I understand, this is a linker error, but Eigen is a header-only project and thus has no library to link against. The code that throws the error follows the basic tutorial they provide, and the offending snippet looks like this:

#include <Eigen/Dense>

using namespace Eigen;

What am I doing wrong? If it helps, I'm running this on Linux. Thanks.


回答1:


Eigen normally gets installed by most distributions to /usr/include/eigen2 and/or /usr/include/eigen3 or similar. Verify where the headers have been installed, as you need to add that path as an additional include path in your project.




回答2:


Check the compiler gets the correct include path. For example, the Eigen library headers may be installed in /usr/include/eigen3, so when compiling you'd have to give the compiler the flag -I /usr/include/eigen3.




回答3:


I was fiddling around and found that telling the Indexer to index unused headers resolved my problem.

Thanks for being on the ball guys. Kind of sorry I stumbled upon it myself.




回答4:


You should not put the headers directly in your project, it makes eclipse horribly slow and sometimes even shows warnings or even (wrong) errors. Instead, you should put the library somewher on disk and link to it (set the propper include directory) via project propperties -> c/c++ General -> GNU C++ -> Add -> File system -> Eigens root folder (where you extracted it to)



来源:https://stackoverflow.com/questions/13593350/including-eigen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!