STD :: Isnan尚未被宣布为G -5
std::isnan has not been declared, with g++-5
我正在尝试用NVCC和G -5编译我的程序,我会收到此错误。
In file included from /usr/include/glm/detail/func_common.hpp:426:0,
from /usr/include/glm/detail/func_geometric.inl:5,
from /usr/include/glm/detail/func_geometric.hpp:113,
from /usr/include/glm/geometric.hpp:6,
from /usr/include/glm/detail/func_matrix.inl:4,
from /usr/include/glm/detail/func_matrix.hpp:149,
from /usr/include/glm/detail/type_mat2x2.inl:4,
from /usr/include/glm/detail/type_mat2x2.hpp:182,
from /usr/include/glm/mat2x2.hpp:6,
from /usr/include/glm/glm.hpp:71,
from src/controls.cpp:6:
/usr/include/glm/detail/func_common.inl:623:14: error: ‘std::isnan’ has not been declared
using std::isnan;
^
/usr/include/glm/detail/func_common.inl:659:14: error: ‘std::isinf’ has not been declared
using std::isinf;
使用G 它正确编译,但是NVCC需要G -5。有人知道如何解决这个问题吗?顺便说一句,一旦我在ubuntu上运行 sudo do-release-upgrade
。
nvcc --version
输出是:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61
g++-5 --version
输出是:
g++-5 (Ubuntu 5.5.0-1ubuntu1) 5.4.1 20171010
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.
g++ --version
输出是:
g++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0
Copyright (C) 2017 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.
我正在使用C 11编译,并且我的源文件中未包含CMATH。这是我的CMakeLists.txt
。
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
set(CMAKE_C_COMPILER /usr/bin/gcc-5 CACHE PATH "" FORCE)
set(CMAKE_CXX_COMPILER /usr/bin/gcc-5 CACHE PATH "" FORCE)
project(cpu_pcd C CXX CUDA)
add_compile_options(-std=c++11)
file(GLOB SRC src/*.cpp src/*.hpp)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)
find_package(GLEW REQUIRED)
find_package(CUDA REQUIRED)
include_directories(src/)
include_directories(${OPENGL_INCLUDE_DIRS})
include_directories(${GLFW_INCLUDE_DIRS})
include_directories(${CUDA_INCLUDE_DIRS})
cuda_add_library(kernel src/update_particles.cu)
cuda_add_executable(cpu_pcd ${SRC})
set_target_properties(cpu_pcd
PROPERTIES CUDA_SEPARABLE_COMPILATION on)
target_link_libraries(cpu_pcd kernel)
target_link_libraries(cpu_pcd ${OPENGL_LIBRARIES} glfw ${GLEW_LIBRARIES} ${CUDA_LIBRARIES} pthread)
您需要在C++11
模式下使nvcc
运行主机C 编译器(直接将此选项传递给GCC是不够的):
nvcc -Xcompiler "-std=c++11"
详细信息可以在此处找到
相关信息:
C 版本由CUDA 5.0
支持使用CUDA和C 11
std :: isnan and std :: isInf在<cmath>
中声明,从C 11开始。包括标头吗?编译是否在C 11或更高版本中进行?
对于那些有兴趣的人,我解决了它更改CMakeLists.txt
的两行:
set(CMAKE_C_COMPILER /usr/bin/gcc-5 CACHE PATH "" FORCE)
set(CMAKE_CXX_COMPILER /usr/bin/g++ CACHE PATH "" FORCE)
现在,它正确地编译了所有愿意提供帮助的人。
相关文章:
- 使用std::multimap迭代器创建std::list
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- 从持续时间构造std::chrono::system_clock::time_point
- std::具有相同基类的类的变体
- std::向量与传递值的动态数组
- 使用std::vector的OpenCL矩阵乘法
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- std::condition_variable::wait()如何评估给定的谓词
- 如何获取std::result_of函数的返回类型
- std::原子加载和存储都需要吗
- 为什么std::isnan 不是 constexpr?
- 为什么 std::isnan() 对于具有 NAN 值的双变量返回 false
- 为什么 g++ 4.9.0 默认有 std::isnan?
- 整型的 std::isnan 和 std::isinf 的重载
- STD :: Isnan尚未被宣布为G -5
- isnan 是否在 std:: 命名空间中?更一般地说,何时是 std::必要、可选或要避免
- 如何将isnan用作std::find_if(c++11)的谓词函数