-1

Eigen is located in the file C:\Users\jherb_000\Downloads\eigen-eigen-07105f7124f9

I thought to include eigen you just use

`#include "C:\Users\jherb_000\Downloads\eigen-eigen-07105f7124f9\Eigen/Dense" `

But it is not compiling. I know it can work because I have done it before, and the eigen website does not explain how to do this unless you are using specific programs like g++.

Jack Herbic
  • 1
  • 1
  • 1

3 Answers3

2

Since you imply via the tags that you're using qt-creator, your problem boils down to "How do I add an include directory in qt-creator?" There are answers for that here, here and others. One thing to note is that the path you should add is C:\Users\jherb_000\Downloads\eigen-eigen-07105f7124f9.

What happens is when you include a specific file in a specific directory, if that file doesn't #include any other files (ok, other files that aren't in the include paths) all works well. But if it does, (and Eigen files include other file in the Eigen project) then the compiler does not know where to search for them. That's why you have to explicitly tell the compiler which directories to look for files that are included.

Community
  • 1
  • 1
Avi Ginsburg
  • 10,323
  • 3
  • 29
  • 56
  • Perhaps the OP is calling `C:\Users\jherb_000\Downloads\eigen-eigen-07105f7124f9` a file (file-folder) when it is actually a _directory_?? – jrsmolley Mar 28 '16 at 04:22
  • @ruffles No, Eigen is unzipped into a directory with a different weird extension each time. Download it and try it. – Avi Ginsburg Mar 28 '16 at 04:25
  • Ok, so I downloaded the .tar.gz from `http://bitbucket.org/eigen/eigen/get/3.2.8.tar.bz2` and unzipped to: `/home/john/downloads/eigen-eigen-07105f7124f9/`. @Avi I'm not sure how the extension would change unless maybe he's following the `INSTALL` file and using `cmake` or `make` every time he tries to build. – jrsmolley Mar 28 '16 at 04:38
  • @ruffles Extension was a poor choice of words. In any case I was referring to versions of Eigen. Download 3.2.7 and you'll see hat I mean. – Avi Ginsburg Mar 28 '16 at 05:00
  • The first one I tried was 3.2.8. The directory for Eigen 3.2.7 once unzipped has become `/home/john/downloads/eigen-eigen-b30b87236a1b/` so yes each version seems to end with a different code. @OP @Jack should download the files to his machine, copy the directory location and _just use it_. – jrsmolley Mar 28 '16 at 05:09
1

Very easy. Let's say you have a dependencies directory, and inside you have the eigen directory. In your .pro file, you could add your dependencies path to your INCLUDEPATH:

INCLUDEPATH += ../dependencies/ # or wherever that path is (relative to your .pro file)

Then, to include the Dense module, you do:

#include <eigen/Dense>

where eigen refers to your folder eigen in your dependencies folder. Many variations possible in function of your setup, but you got the idea.

mfnx
  • 2,894
  • 1
  • 12
  • 28
-1

Ok then what you need to do is:

  1. Copy the C:\Users\jherb_000\Downloads\eigen-eigen-07105f7124f9\Eigen directory and all it's contents to wherever you're keeping all your third-party library files on your machine. (You probably wouldn't want to keep these files in your Downloads folder). For example let's say this directory is copied to C:\jacks_code\Eigen. Then,

  2. Add this new directory to Qt-creator's list of directories to search (see Aki's answer for links):

  3. In each of your source files, to include the Eigen templates, use the preprocessor directive:

    #include <Dense>

The compiler will use the directories you told it, to dereference the file to C:\jacks_code\Eigen\Dense (the complete filename). It's a bit confusing here because the files in the root Eigen folder don't have .h or .c or .cpp or .hpp extensions.

Hope that helps. You can also read the INSTALL file in the base of the unzipped package.

jrsmolley
  • 399
  • 1
  • 7
  • how do you find the header file to use – Jack Herbic Mar 27 '16 at 05:26
  • The eigen documentation / help library / readme should give you a list of files to include in your program. Once you have the entire filepath and filename, you can include it this way. Keep in mind that spaces in the filenames may need to be delimited with the '\' character. For instance: #include "C:\Users\jherb_000\Downloads\eigen-eigen-07105f7124f9\eigenvector.h" to include 'eigenvector.h' at that exact directory. You can explore the directory and see what files there are. – jrsmolley Mar 27 '16 at 05:28
  • so are you saying that the filename of the actual eigen file is what you need after Eigen/Dense? – Jack Herbic Mar 27 '16 at 05:34
  • The entire string in "quotations" needs to be a complete and exact path and filename to a *header* file (more than likely it would end in *.h*) So for example to include a file called "eigenvector.h" in the directory "C:/john/files/", your exact command would be #include "C:/john/files/eigenvector.h" – jrsmolley Mar 27 '16 at 05:38
  • So do you need to include Eigen/Dense at the end? – Jack Herbic Mar 27 '16 at 05:45
  • *You need to enter the filepath and filename, whatever it is* – jrsmolley Mar 27 '16 at 05:50
  • eigen-eigen-07105f7124f9 is the file name – Jack Herbic Mar 27 '16 at 05:54
  • Thanks for the help I still can't get the dumb thing to work. I wish the tutorial would tell how to run eigen on qt – Jack Herbic Mar 27 '16 at 06:29