- edited description
Windows Compilation Issue gtsam::traits
In windows, I get the following compilation issue :
Error : C2027 : use of undefined type 'gtsam::traits><T> when T = const Pose3. This error is not specific to any script or a test function but happens when compiling the core gtsam library which leads me to believe that there are some template restrictions in MSVC that is not present in gcc/clang.
The error further says that 'C3861 : 'Equals': Identifier not found. Which I believe is the same thing as the above error.
@richardroberts , @cbeall3 , @dellaert , Any Ideas ?
Comments (18)
-
reporter -
reporter - edited description
-
@amelim , didn't you run into something like this a couple of weeks ago?
-
Not specifically with the traits, but usually it has to do with template specialization issues.
-
You need to give more context....
-
reporter Based on what I have , it seems like Pose3 is an incomplete type until the end of the function is reached in line 326 , Pose3.h. This is not in the C++ standard. This problem is discussed in this http://stackoverflow.com/questions/3017411/why-does-this-class-declaration-not-work-on-visual-studio link. Jerry Coffin says that this may or may not work.
-
Could you paste some code? I have no function in line 326. And maybe also restate what the post says in our context.
-
reporter Here is what I meant by the previous comment :
In the function "equals_" in "GenericValue.h", the returning value is return traits<T>::Equals(this->value_, genericValue2.value_, tol);
Therefore "Equals" has to be a member of "traits<T>". If T = Pose, then traits is derived from LieGroupTraits, (line 326) , which is inturn derived from Testable.
There is a forward declaration of "struct traits" in Testable.h (Line 46).
But you are already calling a member function, i.e "Equals" in GenericValue.h "traits<T>::Equals", Line 76.
This is what might be causing the "undefined" behavior. After all, the error says
error C2027: use of undefined type 'gtsam::traits<T>' C:\Users\Natesh\borg\gtsam\gtsam\base\GenericValue.h
Does this make sense ?
-
But, where is this called? And why is traits<Pose3> not fully defined at that point?
-
reporter - attached natesh_build.log
-
Here's the log. Still not obvious to my why it's not instantiated by the time dataset.cpp is being compiled.
3>C:\Users\Chris\git\gtsam\gtsam/base/GenericValue.h(76): error C2027: use of undefined type 'gtsam::traits<T>' 3> with 3> [ 3> T=gtsam::Pose3 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/base/GenericValue.h(72) : while compiling class template member function 'bool gtsam::GenericValue<ValueType>::equals_(const gtsam::Value &,double) const' 3> with 3> [ 3> ValueType=gtsam::Pose3 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/nonlinear/Values-inl.h(64) : see reference to class template instantiation 'gtsam::GenericValue<ValueType>' being compiled 3> with 3> [ 3> ValueType=gtsam::Pose3 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/nonlinear/Values-inl.h(62) : while compiling class template member function 'gtsam::_ValuesConstKeyValuePair<ValueType> gtsam::ValuesCastHelper<const ValueType,gtsam::_ValuesConstKeyValuePair<ValueType>,gtsam::Values::ConstKeyValuePair>::cast(KeyValuePairType)' 3> with 3> [ 3> ValueType=gtsam::Pose3 3> , KeyValuePairType=gtsam::Values::ConstKeyValuePair 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/nonlinear/Values-inl.h(145) : see reference to function template instantiation 'gtsam::_ValuesConstKeyValuePair<ValueType> gtsam::ValuesCastHelper<const ValueType,gtsam::_ValuesConstKeyValuePair<ValueType>,gtsam::Values::ConstKeyValuePair>::cast(KeyValuePairType)' being compiled 3> with 3> [ 3> ValueType=gtsam::Pose3 3> , KeyValuePairType=gtsam::Values::ConstKeyValuePair 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/nonlinear/Values-inl.h(141) : see reference to class template instantiation 'gtsam::ValuesCastHelper<const ValueType,gtsam::_ValuesConstKeyValuePair<ValueType>,gtsam::Values::ConstKeyValuePair>' being compiled 3> with 3> [ 3> ValueType=gtsam::Pose3 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/nonlinear/Values-inl.h(129) : while compiling class template member function 'gtsam::Values::Filtered<ValueType>::Filtered(const boost::function<bool (const gtsam::Values::ConstKeyValuePair &)> &,gtsam::Values &)' 3> with 3> [ 3> ValueType=gtsam::Pose3 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/nonlinear/Values-inl.h(232) : see reference to function template instantiation 'gtsam::Values::Filtered<ValueType>::Filtered(const boost::function<bool (const gtsam::Values::ConstKeyValuePair &)> &,gtsam::Values &)' being compiled 3> with 3> [ 3> ValueType=gtsam::Pose3 3> ] 3> C:\Users\Chris\git\gtsam\gtsam/nonlinear/Values-inl.h(162) : see reference to class template instantiation 'gtsam::Values::Filtered<ValueType>' being compiled 3> with 3> [ 3> ValueType=gtsam::Pose3 3> ] 3> C:\Users\Chris\git\gtsam\gtsam\slam\dataset.cpp(405) : see reference to class template instantiation 'gtsam::Values::ConstFiltered<gtsam::Pose3>' being compiled 3>C:\Users\Chris\git\gtsam\gtsam/base/GenericValue.h(76): error C3861: 'Equals': identifier not found 3> The command exited with code 2.
-
You are right: Pose3.h is included, so how is it incomplete? @nsrinivasan7 , try moving Pose3::equals from Pose3.cpp to Pose3.h, see if that resolves it.
-
reporter Changing "equals" function does not work. But I don't think that is the equal that is causing the problem. It is traits<T>::Equals. I am not sure how this is incomplete, all that I can guess is that the compiler does not know that "Equals" exists in traits<T> when T = const Pose3.
This is also strange that it does not happen to Pose2. which also implements traits exactly same. but maybe it will happen once we fix Pose3 .
-
I have no clue :-( @ptf do you guys have "c++ templates on windows" experts?
-
No one I know of. :(
-
We count on you, then, Natesh :-)
-
reporter - changed status to resolved
Fixed in Commit be37e1e
-
reporter @punarjay , this issue is closed now, Can you please try it out on your system ?
- Log in to comment