簡體   English   中英

尚未使用g ++-5聲明std :: isnan

[英]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)

您需要使nvccC++11模式下運行主機C ++編譯器(將此選項直接傳遞給gcc是不夠的):

 nvcc -Xcompiler "-std=c++11"

細節可以在這里找到

相關信息:

cuda 5.0支持的c ++版本

使用CUDA和C ++ 11時出錯

從C ++ 11開始在<cmath>聲明的std :: isnan和std :: isinf。 該標頭包括在內嗎? 編譯是在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)

現在,在所有人的幫助下,它可以正確編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM