Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ including eigen in my makefile

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!

like image 297
MarkJL Avatar asked Oct 24 '11 14:10

MarkJL


1 Answers

(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.

like image 190
James Avatar answered Sep 28 '22 05:09

James