Cython + MSVC14.1 GetDimensions not found in GenericValue.h

Issue #405 new
Firefox Metzger created an issue

I have switched from using the python wrapper to building the cython toolbox instead, as advised in #400. I'm trying to build GTSAM on Windows 10 with Python 3.6 and MSVC 14.1 as well as Boost 1.68.

Now I'm facing a compile time error when building cythonize_gtsam. The build log is attached. (I'm building the release not the debug build, because I only have a release version of the python library, python36.lib.)

The trouble is caused by

6>C:\Users\Sebastian\Documents\Coding Projects\gtsam\gtsam/base/GenericValue.h(152): error C2027: use of undefined type 'gtsam::traits<T>'
6>C:\Users\Sebastian\Documents\Coding Projects\gtsam\gtsam/base/GenericValue.h(152): error C3861: 'GetDimension': identifier not found

in the file GenericValue.h. gtsam::traits is defined in Manifold.h which seems to be included correctly. However, none of the two ManifoldImpl is being picked up. I'm not sure why...

This issue seems to be related to #394 . I'm getting the same errors; however, as I am currently building without the unstable library, the linker errors are of no concern. (They do exist for me though.).

Issue #198 may also be related, though I am not 100% sure.

Any help is appreciated

Comments (6)

  1. Firefox Metzger reporter

    The same problem has also made it's appearance in #332 in the log of Jing Dong. The difference is that I am using VC2017 whereas he is using VC2015. Since there are some Windows machines where it seems to compile, could it be architecture related? I'm using

    • CMake 3.13.0-rc3
    • VC2017 Community v15.9.1 (MSVC++ 14.01)
    • Boost 1.68 (compiled locally)

    I've modified the FindCython.cmake adding brackets around the print statement. This will allow it to run in Python 3 and should still be compatible with Python 2.

    I'm also still puzzled by the traits<T>::GetDimension error. I couldn't find the definition (or declaration for that matter) in GenericValue.h or elsewhere, so it seems that it is indeed missing. Where is the implementation of it? It is used in virtual size_t dim() const which (I suspect) is commonly overloaded by derived classes? Since it doesn't seem to cause issues on Linux or Mac, I am wondering if these compilers ignore the body of the function or find the identifier elsewhere (if so, where?).

    Here is my CMake log:

    Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
    GTSAM_SOURCE_ROOT_DIR: [C:/Users/Sebastian/Documents/Coding Projects/gtsam]
    Boost version: 1.68.0
    Found the following Boost libraries:
      serialization
      system
      filesystem
      thread
      program_options
      date_time
      timer
      chrono
      regex
      atomic
    Ignoring Boost restriction on optional lvalue assignment from rvalues
    [Warning] FindTBB.cmake: The use of TBB_ARCHITECTURE and TBB_COMPILER is deprecated and may not be supported in future versions. Please set $ENV{TBB_ARCH_PLATFORM} (using tbbvars.[bat|csh|sh]).
    TBB: Intel TBB NOT found!
    TBB: Looked for Threading Building Blocks in C:/Program Files/Intel/TBB
    Could NOT find MKL (missing: MKL_INCLUDE_DIR MKL_LIBRARIES) 
    Building 3rdparty
    Could NOT find GeographicLib (missing: GeographicLib_LIBRARY_DIRS GeographicLib_LIBRARIES GeographicLib_INCLUDE_DIRS) 
    Building base
    Building geometry
    Building inference
    Building symbolic
    Building discrete
    Building linear
    Building nonlinear
    Building sam
    Building sfm
    Building slam
    Building smart
    Building navigation
    Adding precompiled header for MSVC
    GTSAM Version: 4.0.0
    Install prefix: C:/Program Files/GTSAM
    Building GTSAM - shared
    Building base_unstable
    Building geometry_unstable
    Building linear_unstable
    Building discrete_unstable
    Building dynamics_unstable
    Building nonlinear_unstable
    Building slam_unstable
    GTSAM_UNSTABLE Version: 4.0.0
    Install prefix: C:/Program Files/GTSAM
    Building GTSAM_UNSTABLE - shared
    Found Cython: ['C:\\Users\\Sebastian\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\Cython'] (found suitable version "0.27.2", minimum required is "0.25.2") 
    Cythonize and build eigency
    Found PythonLibs: C:/Users/Sebastian/AppData/Local/Programs/Python/Python36/libs/python36.lib (found suitable version "3.6.2", minimum required is "2.7") 
    Found NumPy: version "1.14.3" C:/Users/Sebastian/AppData/Local/Programs/Python/Python36/lib/site-packages/numpy/core/include
    Cython wrapper generating gtsam.pyx
    Cythonize and build gtsam.pyx
    Installing Cython Toolbox to C:/Program Files/GTSAM/cython/gtsam
    Cython wrapper generating gtsam_unstable.pyx
    Cythonize and build gtsam_unstable.pyx
    Installing Cython Toolbox to C:/Program Files/GTSAM/cython/gtsam
    Wrote C:/Users/Sebastian/Documents/Coding Projects/gtsam/build/GTSAMConfig.cmake
    Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
    ===============================================================
    ================  Configuration Options  ======================
      CMAKE_CXX_COMPILER_ID type     : MSVC
      CMAKE_CXX_COMPILER_VERSION     : 19.16.27023.1
    Build flags                                               
      Build Tests                    : Enabled
      Build examples with 'make all' : Enabled
      Build timing scripts with 'make all': Disabled
      Build static GTSAM library instead of shared: Disabled
      Put build type in library name : Enabled
      Build libgtsam_unstable        : Enabled
      Use System Eigen               : No
      Use Intel TBB                  : TBB not found
      Eigen will use MKL             : MKL not found
      Eigen will use MKL and OpenMP  : OpenMP found but GTSAM_WITH_EIGEN_MKL is disabled
      Default allocator              : STL
    Packaging flags                                               
      CPack Source Generator         : TGZ
      CPack Generator                : TGZ
    GTSAM flags                                               
      Quaternions as default Rot3     : Disabled
      Runtime consistency checking    : Disabled
      Rot3 retract is full ExpMap     : Disabled
      Pose3 retract is full ExpMap    : Disabled
      Deprecated in GTSAM 4 allowed   : Enabled
      Point3 is typedef to Vector3    : Disabled
      Metis-based Nested Dissection   : Enabled
      Use tangent-space preintegration: Enabled
    MATLAB toolbox flags                                      
      Install matlab toolbox         : Disabled
      Build Wrap                     : Enabled
    Python module flags                                       
      Build python module            : Disabled
    Cython toolbox flags                                      
      Install Cython toolbox         : Enabled
      Build Wrap                     : Enabled
    ===============================================================
    Configuring done
    Generating done
    
  2. Frank Dellaert

    Do a search on GetDimension in whole source. Inheritance hierarchy + traits is a bit baroque... But, why would it fail here and not on other platforms? It works for me on windows, BTW, with no cmake changes. Bizarre!

  3. Firefox Metzger reporter

    Thanks for your reply.

    I have to compile without the Intel libraries since I don't own them (yet); I don't think this is the cause though.

    Compiling the gtsam library itself works fine. What seems to fail is the gtsam.cpp generated by cython as well as the two unstable examples SmartRangeExample_plaza1 and SmartRangeExample_plaza2, so I've excluded the python build for now and focused on the examples that fail with the same error.

    Interestingly, when I comment out the following piece of code:

    for(const Values::ConstFiltered<Point2>::KeyValuePair& it: result.filter<Point2>())
        os2 << it.key << "\t" << it.value.x() << "\t" << it.value.y() << "\t1"
            << endl;
    

    (3 occurences in both files) the project compiles fine, without errors. The culprit seems to be in result.filter<Point2>(), but I have not yet looked into that file specifically.

  4. Firefox Metzger reporter

    I tried compiling the same setup on my Linux (Ubuntu 16.04) workstation and it works without errors. My guess is that it is indeed something regarding how MSVC handles traits.

  5. Frank Dellaert

    You might be right, and windows gtsam users all over the world will love you if you find a fix ;-)

  6. Log in to comment