Windows Compilation Issue gtsam::traits

Issue #201 resolved
Natesh Srinivasan created an issue

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)

  1. Andrew Melim

    Not specifically with the traits, but usually it has to do with template specialization issues.

  2. Frank Dellaert

    Could you paste some code? I have no function in line 326. And maybe also restate what the post says in our context.

  3. Natesh Srinivasan 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 ?

  4. Chris Beall

    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.
    
  5. Frank Dellaert

    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.

  6. Natesh Srinivasan 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 .

  7. Natesh Srinivasan reporter

    @punarjay , this issue is closed now, Can you please try it out on your system ?

  8. Log in to comment