c++在我的 makefile 中包含 eigen

发布于 2024-12-11 17:59:09 字数 1287 浏览 0 评论 0原文

这似乎是我的问题的正确答案,但是我认为这更像是我编写 makefile 的方式,因为我已经有了下面链接中描述的步骤(我知道如何构建东西)。

如何为使用 Eigen(线性代数的 C++ 模板库)的 C++ 项目编写 makefile?

错误:

SASAGeometry.h:6:22: error: Eigen/Core: No such file or directory 
SASAGeometry.h:7:20: error: Eigen/LU: No such file or directory

我的头文件中有问题的行很简单:

#include <Eigen/Core>
#include <Eigen/LU>

所以这是 makefile(我知道 INCLUDE 行中的内容有点过分):

CC = g++
BIN = .

INCLUDE = -I/usr/local/include/eigen2/ -I. -I/usr/local/include/eigen2/Eigen/ -I/home/mark/Applications/eigen/Eigen/src/ -I /usr/local/include

CFLAGS = -pipe

LFLAGS = -lm

GeomTest_OBJS = geomTest.o SASAGeometry.o

geomTest_source = SASAGeometry.cpp SASAGeometry.h sasa_transformMatrix.cpp sasa_transformMatrix.h geomSetup.cpp


geomTest    : $(GeomTest_OBJS) makefile
            $(CC) -o geomTest.o -o SASAGeometry.o $(LIBS) $(INCLUDE) $(CFLAGS) $(geomTest_source) $(LFLAGS)
            $(CC) $(LIBS) $(INCLUDE) $(CFLAGS) -o $(BIN)/geomTest geomTest.o SASAGeometry.o $(LFLAGS)

clean       : \rm *.o *~ p1

有什么想法吗?

提前致谢!

This seems to be the correct answer to my problem, however I think it's more the way I am writing my makefile as I already have the steps described in the link below (I know how to build things).

How to write a makefile for a C++ project which uses Eigen, the C++ template library for linear algebra?

Error:

SASAGeometry.h:6:22: error: Eigen/Core: No such file or directory 
SASAGeometry.h:7:20: error: Eigen/LU: No such file or directory

The problematic lines in my header file are simply :

#include <Eigen/Core>
#include <Eigen/LU>

So here is the makefile (am on overkill in the INCLUDE line, I know):

CC = g++
BIN = .

INCLUDE = -I/usr/local/include/eigen2/ -I. -I/usr/local/include/eigen2/Eigen/ -I/home/mark/Applications/eigen/Eigen/src/ -I /usr/local/include

CFLAGS = -pipe

LFLAGS = -lm

GeomTest_OBJS = geomTest.o SASAGeometry.o

geomTest_source = SASAGeometry.cpp SASAGeometry.h sasa_transformMatrix.cpp sasa_transformMatrix.h geomSetup.cpp


geomTest    : $(GeomTest_OBJS) makefile
            $(CC) -o geomTest.o -o SASAGeometry.o $(LIBS) $(INCLUDE) $(CFLAGS) $(geomTest_source) $(LFLAGS)
            $(CC) $(LIBS) $(INCLUDE) $(CFLAGS) -o $(BIN)/geomTest geomTest.o SASAGeometry.o $(LFLAGS)

clean       : \rm *.o *~ p1

any thoughts?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

为你拒绝所有暧昧 2024-12-18 17:59:09

(注意,阅读评论以获取最终解决方案的要点。当我从问题的原始发布者那里得到澄清时,我会更新答案。)

有时这是显而易见的,很容易被忽略。请检查您的用户是否具有 /usr/local/include/eigen2 和 /usr/local/include/eigen2/Eigen 中所有文件和目录的读取权限。还要仔细检查您要包含的文件是否实际存在于 /usr/local/include/eigen2/Eigen 中。

额外的:
听起来安装是直接部署到 /usr/include/eigen2 中的,而不是像文档假设的那样部署到 /usr/include/Eigen 中。这意味着教程想要的头文件位于 /usr/include/eigen2 中。你的 -I 需要指向 /usr/include/ (我认为这是 GNU GCC 中默认的)。您的源代码不正确,应该是 #include#include。在您的系统上安装 eigen 的人更改了文档中指定的根目录的名称。

(Note, read comments to get gist of the final solution. I will update the answer when I have clarification from the original poster of the question.)

Sometimes it is the obvious, which is easy to miss. Please check that your user has read permissions for all files and directories in /usr/local/include/eigen2 and /usr/local/include/eigen2/Eigen. Also double check the files you are including actually exist in /usr/local/include/eigen2/Eigen.

Additional:
It sounds like the install was deployed directly into /usr/include/eigen2 and NOT /usr/include/Eigen like the documentation assumes. That means the header files the tutorials want are in /usr/include/eigen2. Your -I needs to point to /usr/include/ (I think thats by default in GNU GCC). Your source code is incorrect, it should be #include <eigen2/Core> and #include <eigen2/LU>. Whoever installed eigen on your system changed the name of the root directory specified in the documentations.

凤舞天涯 2024-12-18 17:59:09

您链接到的问题有正确答案。您只需要使用正确的 -I 标志来指向 Eigen 标头。对于所有 Eigen 标头,您应该只需要一个 -I

The question you link to has the correct answer. You just need to use the proper -I flag to point to the Eigen headers. You should only need one -I for all of the Eigen headers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文