<vtkgenericdataarraylookuphelper.h:语法=“” error =“”>,编译VTK-8.90

时间:2019-03-25 19:12:12

标签: c++ vtk

正如标题所述,我在从github来源编译最新版本的VTK时遇到问题。

我不是c ++程序员,只对代码有基本的了解。到目前为止,我一直尝试/调查/搜索都无济于事:

  • 关闭.h文件/查找错误的空格/制表符。 (我没想到这会做任何事情)
  • 我的本地git repo的硬重置
  • 尝试使用gcc-8和标准链接器(/ usr / bin / ld)进行编译
  • 尝试使用clang和llvm链接器(/usr/bin/ld.lld)进行编译
  • 尝试了基本编译(两者),而我不需要任何额外的模块。
  • 更新了我的发行版/ clang / gcc / llvm

我不知道从这里去哪里。我确定这是我自己的事情,因为我没有从Google搜索中找到与此相关的任何问题。

这是我收到的没有任何额外输出的错误(来自clang编译的错误,但与gcc相同):

`Scanning dependencies of target WrapHierarchy
[  8%] Building C object Wrapping/Tools/CMakeFiles/WrapHierarchy.dir/vtkWrapHierarchy.c.o
[  8%] Linking C executable ../../bin/vtkWrapHierarchy-8.90
Scanning dependencies of target CommonCore-hierarchy
[  8%] Generating the wrap hierarchy for VTK::CommonCore
vtkWrapHierarchy-8.90: In /src/VTK/Common/Core/vtkGenericDataArrayLookupHelper.h:40: syntax error.
make[2]: *** [Common/Core/CMakeFiles/CommonCore-hierarchy.dir/build.make:260: lib/vtk/hierarchy/VTK/vtkCommonCore-hierarchy.txt] Error 1
make[1]: *** [CMakeFiles/Makefile2:6418: Common/Core/CMakeFiles/CommonCore-hierarchy.dir/all] Error 2
make: *** [Makefile:130: all] Error 2`

这是设置-v链接器标志时的错误输出:

`[  8%] Built target WrappingPythonCore
Scanning dependencies of target WrapHierarchy
[  8%] Building C object Wrapping/Tools/CMakeFiles/WrapHierarchy.dir/vtkWrapHierarchy.c.o
[  8%] Linking C executable ../../bin/vtkWrapHierarchy-8.90
clang version 8.0.0-1ubuntu1 (tags/RELEASE_800/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
Found CUDA installation: /usr/lib/cuda, version 10.0
 "/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o ../../bin/vtkWrapHierarchy-8.90 /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/8/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/8 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/lib -L/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../.. -L/usr/lib/llvm-8/bin/../lib -L/lib -L/usr/lib CMakeFiles/WrapHierarchy.dir/vtkWrapHierarchy.c.o ../../lib/libvtkWrappingTools-8.90.a -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-linux-gnu/8/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crtn.o
[  8%] Built target WrapHierarchy
Scanning dependencies of target CommonCore-hierarchy
[  8%] Generating the wrap hierarchy for VTK::CommonCore
vtkWrapHierarchy-8.90: In /src/VTK/Common/Core/vtkGenericDataArrayLookupHelper.h:40: syntax error.
make[2]: *** [Common/Core/CMakeFiles/CommonCore-hierarchy.dir/build.make:260: lib/vtk/hierarchy/VTK/vtkCommonCore-hierarchy.txt] Error 1
make[1]: *** [CMakeFiles/Makefile2:6418: Common/Core/CMakeFiles/CommonCore-hierarchy.dir/all] Error 2
make: *** [Makefile:130: all] Error 2`

这是引用的.h文件:

=========================================================================*/

    /**
     * @class   vtkGenericDataArrayLookupHelper
     * @brief   internal class used by
     * vtkGenericDataArray to support LookupValue.
     *
    */

    #ifndef vtkGenericDataArrayLookupHelper_h
    #define vtkGenericDataArrayLookupHelper_h

    #include <algorithm>
    #include <cmath>
    #include "vtkIdList.h"

    namespace detail
    {
    // this can be removed when C++11 is required.
    template< class T > struct remove_const { typedef T type; };
    template< class T > struct remove_const<const T> { typedef T type; };

    template <typename T, bool> struct has_NaN;

    template <typename T>
    struct has_NaN<T, true>
    {
    static bool isnan(T x)
    {
      return std::isnan(x);
    }
    };

    template <typename T>
    struct has_NaN<T, false>
    {
      static bool isnan(T)
      {
        return false;
      }
    };

    template <typename T>
    bool isnan(T x)
    {
      // Select the correct partially specialized type.
      return has_NaN<T, std::numeric_limits<T>::has_quiet_NaN>::isnan(x);
    }
    }

    template <class ArrayTypeT>
    class vtkGenericDataArrayLookupHelper
    {
    public:
      typedef ArrayTypeT ArrayType;
      typedef typename ArrayType::ValueType ValueType;

      // Constructor.
      vtkGenericDataArrayLookupHelper()
        : AssociatedArray(nullptr), SortedArray(nullptr),
        FirstValue(nullptr), SortedArraySize(0)
      {
      }
      ~vtkGenericDataArrayLookupHelper()
      {
        this->ClearLookup();
      }

      void SetArray(ArrayTypeT *array)
      {
        if (this->AssociatedArray != array)
        {
          this->ClearLookup();
          this->AssociatedArray = array;
        }
      }

      vtkIdType LookupValue(ValueType elem)
      {
        this->UpdateLookup();

        if (this->SortedArraySize == 0)
        {
          return -1;
        }

        if(::detail::isnan(elem))
        {
          if(this->SortedArray && ::detail::isnan(this->SortedArray->Value))
          {
            return this->SortedArray->Index;
          }
          else
          {
            return -1;
          }
        }

        ValueWithIndex temp;
        temp.Value = elem;
        ValueWithIndex* pos =
          std::lower_bound(this->FirstValue,
                         this->SortedArray + this->SortedArraySize, temp);
        if (pos == (this->SortedArray + this->SortedArraySize))
        {
          return -1;
        }
        if (pos->Value != elem)
        {
          return -1;
        }
        return pos->Index;
      }

      void LookupValue(ValueType elem, vtkIdList* ids)
      {
        ids->Reset();
        this->UpdateLookup();

        if (this->SortedArraySize == 0)
        {
         return;
        }

        if(::detail::isnan(elem))
        {
          ValueWithIndex *range = this->SortedArray;
          while (range != this->FirstValue)
          {
            ids->InsertNextId(range->Index);
            ++range;
          }
        }
        else
        {
          ValueWithIndex temp;
          temp.Value = elem;
          std::pair<ValueWithIndex*, ValueWithIndex*> range =
            std::equal_range(this->FirstValue,
                             this->SortedArray + this->SortedArraySize, temp);
          while (range.first != range.second)
          {
            // assert(range.first->Value == elem);
            ids->InsertNextId(range.first->Index);
            ++range.first;
          }
        }
      }

      //@{
      /**
       * Release any allocated memory for internal data-structures.
       */
      void ClearLookup()
      {
        free(this->SortedArray);
        this->SortedArray = nullptr;
        this->SortedArraySize = 0;
      }
      //@}

    private:
      vtkGenericDataArrayLookupHelper(const vtkGenericDataArrayLookupHelper&) = delete;
      void operator=(const vtkGenericDataArrayLookupHelper&) = delete;

      struct ValueWithIndex
      {
        typename ::detail::remove_const<ValueType>::type Value;
        vtkIdType Index;
        inline bool operator<(const ValueWithIndex& other) const
        {
          return this->Value < other.Value;
        }
      };

      static bool isnan(const ValueWithIndex &tmp)
      {
        return ::detail::isnan(tmp.Value);
      }

      void UpdateLookup()
      {
        if (!this->AssociatedArray || this->SortedArray)
        {
          return;
        }

        int numComps = this->AssociatedArray->GetNumberOfComponents();
        this->SortedArraySize =
            this->AssociatedArray->GetNumberOfTuples() * numComps;

        if (this->SortedArraySize == 0)
        {
          return;
        }

        this->SortedArray = reinterpret_cast<ValueWithIndex*>(
              malloc(this->SortedArraySize * sizeof(ValueWithIndex)));
        for (vtkIdType cc = 0, max = this->AssociatedArray->GetNumberOfValues();
             cc < max; ++cc)
        {
          ValueWithIndex& item = this->SortedArray[cc];
          item.Value = this->AssociatedArray->GetValue(cc);
          item.Index = cc;
        }
        this->FirstValue = std::partition(this->SortedArray, this->SortedArray + this->SortedArraySize, isnan);
        std::sort(this->FirstValue, this->SortedArray + this->SortedArraySize);
      }

      ArrayTypeT *AssociatedArray;
      ValueWithIndex* SortedArray;
      ValueWithIndex* FirstValue;
      vtkIdType SortedArraySize;
    };

    #endif
    // VTK-HeaderTest-Exclude: vtkGenericDataArrayLookupHelper.h

0 个答案:

没有答案