Re: [eigen] shared libraries and including Eigen in base class

[ Thread Index | Date Index | More Archives ]

thank you, patch applied.


On Tue, Jun 8, 2010 at 7:00 PM, Trevor Irons <trevorirons@xxxxxxxxx> wrote:
Indeed, thanks. This fixed things as far as I can tell.

Patch attached if no objections. Both functions required inline to compile for me.

On 8 June 2010 10:51, joel falcou <joel.falcou@xxxxxx> wrote:
Trevor Irons wrote:
I have a quick question

With the following classes

// base.h
#ifndef  BASE_INC
#define  BASE_INC
#include <Eigen/Eigen>
class Base {
       Base ();                           ~Base ();                   }; // -----  end of class  Base  -----
#endif   // ----- #ifndef BASE_INC  -----

// base.cpp
#include "base.h"
Base::Base() {}
Base::~Base() {}

// derived.h
#ifndef  DERIVED_INC
#define  DERIVED_INC
#include "base.h"
class Derived : public Base {
       Derived ();                           ~Derived ();                   }; // -----  end of class  Derived  -----
#endif   // ----- #ifndef DERIVED_INC  -----

#include "derived.h"
Derived::Derived() {}
Derived::~Derived() {}

If I compile these into a static library, all is fine. But using gcc and compiling into a shared library, the objects are made fine, but the call to the linker fails.

g++ -o base.os -c -fPIC -I/home/tirons/src/eigen base.cpp
g++ -o derived.os -c -fPIC -I/home/tirons/src/eigen derived.cpp

g++ -o -shared base.os derived.os

derived.os: In function `Eigen::l1CacheSize()':
derived.cpp:(.text+0x25cf): multiple definition of `Eigen::l1CacheSize()'
base.os:base.cpp:(.text+0x25cf): first defined here
derived.os: In function `Eigen::setL1CacheSize(long)':
derived.cpp:(.text+0x25f8): multiple definition of `Eigen::setL1CacheSize(long)'
base.os:base.cpp:(.text+0x25f8): first defined here

Is there some way around this? This type of code has been fine before some recent changes. I know these changes should help performance though. Maybe there are compelling reasons why you shouldn't be including Eigen in any base classes?

Thanks again,

Sounds some inline is missing on these functions.

Mail converted by MHonArc 2.6.19+