This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: advice about setting up the eigen library for use with cygwin g++


Csaba Raduly wrote:
> Hi,
> 
> On Thu, Dec 4, 2014 at 10:43 PM, LMH  wrote:
>> Hello,
>>
>> As stated, I am writing a few tools with cygwin g++.
> (snip)
>> Eigen is a header only kind  of thing, so my understanding is that all I
>> need to do is to unpack the src somewhere add the location to the
>> include path.
>>
>> I was thinking of putting Eigen in,
>>
>> /cygdrive/c/cygwin/lib/eigen/
> 
> If you use Cygwin tools, you shouldn't use paths like
> "/cygdrive/c/cygwin/lib". The way to refer to
> that directory is /lib (unless your Cygwin is installed somewhere
> other than C:\cygwin).
> 
>>
>> and using,
>>
>> g++ -I /cygdrive/c/cygwin/lib/eigen/
>>
> 
> /lib is not really for headers. It mostly contains binaries. A
> canonical place for a header-only library would be
> /usr/local/include/eigen
> 
> Doesn't eigen supply a makefile with an "install" target?
> 
> Csaba
> 


Hello Csaba,

Thanks for the information. I will take your advice and unpack Eigen in
/usr/local/include/eigen instead of in /lib and drop the /cygdrive/c/
from the include path.

As I mentioned in an earlier post, Eigen is not a compiled library,
meaning there is no binary file. As I understand it, you are just
supposed to use the src code and header files as is, like you would use
any other .cpp and .h files in your build. The main difference is that
the files are not located in your trunk src directory.

Yaakov Selkowitz mentioned that Eigen is available through ports. I have
never used ports, so I'm not sure what the difference is. Is there a
difference in the way the Eigen code gets linked to my app if I install
Eigen through ports?

According to the Eigen page, Eigen isn't installed in the formal sense,
like you would install boost through the cygwin package manager. You
just put the Eigen folder somewhere and add the top level to the include
path. When you write your src, you add includes for the header files you
want and compile/link as normal.

"If you just want to use Eigen, you can use the header files right away.
There is no binary library to link to, and no configured header file.
Eigen is a pure template library defined in the headers."

This is a sample program from the getting started page,

## my_program.cpp ##

#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;

int main() {
  MatrixXd m(2,2);
  m(0,0) = 3;
  m(1,0) = 2.5;
  m(0,1) = -1;
  m(1,1) = m(1,0) + m(0,1);
  std::cout << m << std::endl;
}

g++ -I /path/to/eigen/ my_program.cpp -o my_program

According to the same page, if you have the Eigen folder, or a symlink
to the Eigen folder, in /usr/local/include/, you don't need to use -I.

So I guess I still need to figure out if this is going to work as I
understand it and if there is some advantage to installing Eigen through
ports instead of just unpacking it.

LMH

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]