Registered Member
|
Hi
I'm having troubles for exporting a class that derives from an Eigen::Matrix under windows. More specifically, following code:
Produces a warning C4251: warning C4251: 'Eigen::Matrix<_Scalar,_Rows,_Cols>::m_storage' : class 'Eigen::ei_matrix_storage<T,Size,_Rows,_Cols,_Options>' needs to have dll-interface to be used by clients of class 'Eigen::Matrix<_Scalar,_Rows,_Cols>' and 5 errors C2487 : error C2487: 'Eigen::MatrixBase<Derived>::setConstant' : member of dll interface class may not be declared with dll interface 'Eigen::MatrixBase<Derived>::setZero' : member of dll interface class may not be declared with dll interface 'Eigen::MatrixBase<Derived>::setOnes' : member of dll interface class may not be declared with dll interface 'Eigen::MatrixBase<Derived>::setRandom' : member of dll interface class may not be declared with dll interface 'Eigen::MatrixBase<Derived>::setIdentity' : member of dll interface class may not be declared with dll interface The warning can be removed using explicit template instantiation, ie writing following lines before the declaration of myVector:
But I think that the error C2487 is due to a flaw in Visual Studio's compiler when instantiating Derived in MatrixBase.h. Here (MatrixBase.h, line 443) 'Derived' is replaced by '__declspec(dllexport) Eigen::Matrix<double, 3, 1>' so that the declaration of the method setConstant() (and others) looks like a member declared with dll interface. What is the right way for exporting a class that inherits from a instantiation of an EigenMatrix? Thanks for your help Steph |
Registered Member
|
I have a similar problem. I want to create a static library with VS on Windows.
What should I consider for exporting the right stuff. Thanks for your help. Best wishes Stephan |
Registered Member
|
Hi,
was there ever any solution (or at least a workaround) to this problem? Current KDE trunk has the exact same problem (in kdebase\runtime\nepomuk\services\backupsync\lib\simpleresource.h) An exported class that derives from QMultiHash<Foo, Bar> and which throws the same error in MSVC. Edit: kdepim also suffers from this in kdepim\mailcommon\filteraction.h -Darkstar
This is not a signature...
|
Registered Member
|
Same problem again with nepomuk-core.
|
Registered Member
|
This is not a signature...
|
Registered Member
|
I do not see this error message mentioned there. As if different ones had been discussed in there, but I may be wrong as I am a no expert about msvc.
|
Registered Member
|
The problem is with template instantiations. DLL files cannot export non-instantiated templates. These must be self-contained in the .h file.
this is, generally, a quite difficult problem because depending on the source code it requires quite a lot of changes
This is not a signature...
|
Registered Member
|
I presume the problem is also that nepomuk-core should keep the binary compatibility and this might make the situation very difficult.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]