c++ - 使用 CUDA 和 C++ 运行现有项目

标签 c++ c++11 gcc cuda

我正在尝试运行 this项目在我的笔记本电脑中。我安装了以下东西。

CUDA:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

海湾合作委员会:

gcc (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

CMake:

cmake version 3.5.1

make 期间。项目报错如下。

/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

如果我将 set (CMAKE_CXX_STANDARD 11) 添加到 CMakesLists.txt 以支持 c++ 标准 11。我收到以下错误。

In file included from /usr/include/mrpt/base/include/mrpt/utils.h:25:0,
                 from /home/muazzam/mywork/python/thesis/PD-Flow/scene_flow_visualization.h:24,
                 from /home/muazzam/mywork/python/thesis/PD-Flow/main_scene_flow_visualization.cpp:24:
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:253:8: error: ‘std::enable_if_t’ has not been declared
   std::enable_if_t<is_shared_ptr<T>::value>* = nullptr)
        ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:253:19: error: expected ‘,’ or ‘...’ before ‘<’ token
   std::enable_if_t<is_shared_ptr<T>::value>* = nullptr)
                   ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:263:8: error: ‘std::enable_if_t’ has not been declared
   std::enable_if_t<!is_shared_ptr<T>::value>* = nullptr)
        ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:263:19: error: expected ‘,’ or ‘...’ before ‘<’ token
   std::enable_if_t<!is_shared_ptr<T>::value>* = nullptr)
                   ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:261:6: error: ‘template<class RET, class T, class ... R> RET mrpt::utils::CStream::ReadVariant_helper(mrpt::utils::CSerializable::Ptr&, int)’ cannot be overloaded
  RET ReadVariant_helper(
      ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:251:6: error: with ‘template<class RET, class T, class ... R> RET mrpt::utils::CStream::ReadVariant_helper(mrpt::utils::CSerializable::Ptr&, int)’
  RET ReadVariant_helper(
      ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h: In member function ‘void mrpt::utils::CStream::WriteVariant(T)’:
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:314:15: error: use of ‘auto’ in lambda parameter declaration only available with -std=c++14 or -std=gnu++14
   t.match([&](auto& o) { this->WriteObject(o); });
               ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h: In lambda function:
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:314:45: error: no matching function for call to ‘mrpt::utils::CStream::WriteObject(int&)’
   t.match([&](auto& o) { this->WriteObject(o); });
                                             ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:197:7: note: candidate: void mrpt::utils::CStream::WriteObject(const mrpt::utils::CSerializable*) <near match>
  void WriteObject(const CSerializable* o);
       ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:197:7: note:   conversion of argument 1 would be ill-formed:
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:198:7: note: candidate: void mrpt::utils::CStream::WriteObject(const mrpt::utils::CSerializable&)
  void WriteObject(const CSerializable& o) { WriteObject(&o); }
       ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:198:7: note:   no known conversion for argument 1 from ‘int’ to ‘const mrpt::utils::CSerializable&’
/usr/include/mrpt/base/include/mrpt/utils/CStream.h: At global scope:
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:524:28: error: ‘std::enable_if_t’ has not been declared
 template <typename T, std::enable_if_t<std::is_base_of<
                            ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:524:39: error: expected ‘>’ before ‘<’ token
 template <typename T, std::enable_if_t<std::is_base_of<
                                       ^
/usr/include/mrpt/base/include/mrpt/utils/CStream.h: In function ‘mrpt::utils::CStream& mrpt::utils::operator<<(mrpt::utils::CStream&, const mapbox::util::variant<Types ...>&)’:
/usr/include/mrpt/base/include/mrpt/utils/CStream.h:545:17: error: use of ‘auto’ in lambda parameter declaration only available with -std=c++14 or -std=gnu++14
  pObj.match([&](auto& t) { out << t; });
                 ^
In file included from /usr/include/mrpt/base/include/mrpt/utils/TCamera.h:15:0,
                 from /usr/include/mrpt/base/include/mrpt/utils/CImage.h:16,
                 from /usr/include/mrpt/base/include/mrpt/utils.h:38,
                 from /home/muazzam/mywork/python/thesis/PD-Flow/scene_flow_visualization.h:24,
                 from /home/muazzam/mywork/python/thesis/PD-Flow/main_scene_flow_visualization.cpp:24:
/usr/include/mrpt/base/include/mrpt/utils/CConfigFileBase.h: At global scope:
/usr/include/mrpt/base/include/mrpt/utils/CConfigFileBase.h:80:22: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
      typename = std::enable_if_t<std::is_enum<enum_t>::value>>
                      ^
/usr/include/mrpt/base/include/mrpt/utils/CConfigFileBase.h:80:33: error: expected ‘>’ before ‘<’ token
      typename = std::enable_if_t<std::is_enum<enum_t>::value>>
                                 ^
/usr/include/mrpt/base/include/mrpt/utils/CConfigFileBase.h:96:22: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
      typename = std::enable_if_t<!std::is_enum<data_t>::value>>
                      ^
/usr/include/mrpt/base/include/mrpt/utils/CConfigFileBase.h:96:33: error: expected ‘>’ before ‘<’ token
      typename = std::enable_if_t<!std::is_enum<data_t>::value>>
                                 ^
In file included from /home/muazzam/mywork/python/thesis/PD-Flow/main_scene_flow_visualization.cpp:24:0:
/home/muazzam/mywork/python/thesis/PD-Flow/scene_flow_visualization.h:93:13: error: ‘COpenGLScenePtr’ in namespace ‘mrpt::opengl’ does not name a type
     opengl::COpenGLScenePtr  scene;
             ^
CMakeFiles/Scene-Flow-Visualization.dir/build.make:62: recipe for target 'CMakeFiles/Scene-Flow-Visualization.dir/main_scene_flow_visualization.o' failed
make[2]: *** [CMakeFiles/Scene-Flow-Visualization.dir/main_scene_flow_visualization.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Scene-Flow-Visualization.dir/all' failed
make[1]: *** [CMakeFiles/Scene-Flow-Visualization.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

现在我不知道如何进行这项工作。我该如何构建这个项目?

最佳答案

std::enable_if_t 仅在 C++14 中引入,因此您应该将所需标准设置为 C++14:

set(CMAKE_CXX_STANDARD 14)

关于c++ - 使用 CUDA 和 C++ 运行现有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46432222/

相关文章:

c - C 程序中与 awk 语法冲突

C++ 在 { 标记之前期望类名,继承错误

c++ - 在 C++ 换行符之前如何获取输入?

c++ - 为什么 sizeof(str.substr(0,3).c_str()) 给我 8?

c++ - boost::shared_ptr 没有类类型

c++ - 如何在文件中存储每 channel 16 位的图像?

c - 是否有可以指示任何类型更改的 GCC 警告?

c++ - 将 D 库链接到 C++ 代码

c++ - -std=c++11 标志在 gcc/g++ 4.4.6 中无法识别

c - 为内联汇编参数打开即时值传播的特定 GCcflags是什么?