编译CUDA和PCL点云库的出错问题

今天在编写一个同时使用CUDA和PCL的程序时,发现编译始终报错:

  • 一个是警告信息:
CMake Warning (dev) in cuda_gpu_generated_test.cu.o.cmake:
  Syntax Warning in cmake code at

    /home/xxx/mytsdf-fusion/build/mytsdf/CMakeFiles/cuda_gpu.dir/src/cuda_gpu_generated_test.cu.o.cmake:79:137

  Argument not separated from preceding token by whitespace.
This warning is for project developers.  Use -Wno-dev to suppress it.
  • 一个是错误:
nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified
CMake Error at cuda_gpu_generated_test.cu.o.cmake:207 (message):
  Error generating
  /home/xxx/mytsdf-fusion/build/mytsdf/CMakeFiles/cuda_gpu.dir/src/./cuda_gpu_generated_test.cu.o


mytsdf/CMakeFiles/cuda_gpu.dir/build.make:63: recipe for target 'mytsdf/CMakeFiles/cuda_gpu.dir/src/cuda_gpu_generated_test.cu.o' failed

在网上查找了一些资料后,发现需要在CMakeLists.txt的依赖项后中添加:

get_directory_property(dir_defs DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
set(vtk_flags)
foreach(it ${dir_defs})
    if(it MATCHES "vtk*")
    list(APPEND vtk_flags ${it})
    endif()
endforeach()

foreach(d ${vtk_flags})
    remove_definitions(-D${d})
endforeach()

并在cuda的依赖项后添加

set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--disable-warnings;--ptxas-options=-v;-use_fast_math;-lineinfo;-std=c++11)

这样就可以成功编译了。


参考:

https://www.jianshu.com/p/1dc40d2b78c8

你可能感兴趣的:(基础准备)