继续上一篇博客的工作,不得不说,要用一个论文里的implementation,得做这么多额外的、没有技术含量的工作,也是醉了。希望以后论文的作者们,在公布implementation的时候,也想想别人的工作量,你自己用自己熟悉的库,C++、Python混用,但别人可能只习惯Python啊。
这里总结一下怎么在Ubuntu上安装Eigen3,顾名思义,这应该是一个进行矩阵运算操作的库。
首先在这个页面下看看:https://eigen.tuxfamily.org/dox/GettingStarted.html,发现果然不出所料,根本不会讲环境变量设置等问题。这个页面中只简单提了两句:
There is no library to link to. The only thing that you need to keep in mind when compiling the above program is that the compiler must be able to find the Eigen header files. The directory in which you placed Eigen's source code must be in the include path.
我们还是自己尝试一下,先在这里:http://eigen.tuxfamily.org/index.php?title=Main_Page#Download,下载其源码压缩包。解压之后看到有一个INSTALL的文件,打开之后会介绍,如果使用CMake来进行安装的话,有以下步骤:
Let's call this directory 'source_dir' (where this INSTALL file is).
Before starting, create another directory which we will call 'build_dir'.Do:
cd build_dir
cmake source_dir
make installThe "make install" step may require administrator privileges.
其实这个说得还是比较清楚的。唯一需要注意的是,最后一步是:
sudo make install
然后就需要注意一个问题,其实别的朋友也发现了:https://blog.csdn.net/wonengguwozai/article/details/68932309
很多人说运行完上述操作后,Eigen3会被安装在/usr/include中,想这个implementation的作者也这样说:https://github.com/luckiezhou/DynamicTriad/issues/5,我不知道为啥会以讹传讹成这个样子,也不知道Eigen3的作者们知不知道他们的安装过程和很多教程不一样,也不想着修改么?
先不吐槽,在执行上面make命令的时候,我们也可以注意到,实际上是被复制到了:/usr/local/include/eigen3/这个目录下。
感觉这个目录并不是直接的include path,估计编译的时候会出问题,试了一下,果然报:
fatal error: Eigen/Core: 没有那个文件或目录
#include <Eigen/Core>
^~~~~~~~~~~~
compilation terminated.
呵呵,所以按照其他网友的建议(https://blog.csdn.net/p942005405/article/details/100653731),需要运行:
sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include
另外,按照repo作者的建议,我还加了一个环境变量,sudo gedit /etc/profile——export EIGEN3_INCLUDE_DIR=/usr/local/include——source /etc/profile,说实话,我也不知道这个环境变量是否有用。反正修改了上述设置之后,再编译就不报错了,呵呵呵,反正从开发者到使用者,没有人能把这个过程总结清楚,还得让网友们自己的总结、猜、填坑,这些事情实在太浪费生命了。