Boost.Geometry搭配CUDA 12.4的NVCC编译错误:‘__T0’未定义类型
CUDA 12.4 NVCC编译Boost.Geometry项目时出现类型命名错误
使用Boost.Geometry结合CUDA 12.4的NVCC编译项目时遭遇编译错误,单独用GCC编译可正常通过,但引入NVCC后,会在Boost.Geometry的sectionalize.hpp文件中抛出类型命名相关错误。该问题仅出现在CUDA 12.4版本,12.3及以下版本无此问题。
环境信息
- 编译器:GCC 9.5.0、CUDA 12.4附带的NVCC
- Boost版本:1.84.0
- 构建系统:Makefile
错误日志
[ 33%] Building CUDA object CMakeFiles/testGeometry.dir/main.cu.o /home/marekz/boost-1.84.0/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp: In function ‘void boost::geometry::detail::sectionalize::enlarge_sections(Sections&, const Strategy&)’: /home/marekz/boost-1.84.0/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp:739:12: error: ‘__T0’ does not name a type; did you mean ‘__y0’? 739 | using gt = decltype(section.bounding_box); | ^~~~ | __y0 /home/marekz/boost-1.84.0/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp:740:38: error: ‘__T0’ was not declared in this scope; did you mean ‘__y0’? 740 | using ct = typename geometry::coordinate_type<gt>::type; | ^~~~ | __y0 /home/marekz/boost-1.84.0/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp:740:42: error: template argument 1 is invalid 740 | using ct = typename geometry::coordinate_type<gt>::type; | ^ /home/marekz/boost-1.84.0/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp:741:14: error: ‘ct’ does not name a type; did you mean ‘cs’? 741 | static ct const eps = math::scaled_epsilon<ct>(1000); | ^~ | cs /home/marekz/boost-1.84.0/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp:742:43: error: ‘eps’ was not declared in this scope 742 | expand_by_epsilon(section.bounding_box, eps); | ^~~ make[3]: *** [CMakeFiles/testGeometry.dir/build.make:76: CMakeFiles/testGeometry.dir/main.cu.o] Error 1 make[2]: *** [CMakeFiles/Makefile2:83: CMakeFiles/testGeometry.dir/all] Error 2 make[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/testGeometry.dir/rule] Error 2 make: *** [Makefile:124: testGeometry] Error 2
复现代码
CMakeLists.txt
cmake_minimum_required(VERSION 3.22) project(testGeometry CXX) set(CMAKE_C_COMPILER "/usr/bin/gcc-9") set(CMAKE_CXX_COMPILER "/usr/bin/g++-9") set(CMAKE_CUDA_HOST_COMPILER "/usr/bin/g++-9") set(CMAKE_CXX_STANDARD 17) enable_language(CUDA) include(FindCUDAToolkit) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --std c++17") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --maxrregcount 32") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr") set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/home/marekz/boost-1.84.0/lib/cmake") find_package(Boost REQUIRED) add_executable(${PROJECT_NAME} main.cu) target_link_libraries(${PROJECT_NAME} PUBLIC CUDA::cudart Boost::headers PRIVATE CUDA::curand CUDA::cusolver )
main.cu
#include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <iostream> int main() { // Define the point type using point_t = boost::geometry::model::d2::point_xy<double>; // Define the polygon type using polygon_t = boost::geometry::model::polygon<point_t>; // Create a point point_t point(5.0, 5.0); // Create a polygon polygon_t poly; boost::geometry::append(poly.outer(), point_t(0.0, 0.0)); boost::geometry::append(poly.outer(), point_t(0.0, 10.0)); boost::geometry::append(poly.outer(), point_t(10.0, 10.0)); boost::geometry::append(poly.outer(), point_t(10.0, 0.0)); boost::geometry::append(poly.outer(), point_t(0.0, 0.0)); // Calculate the distance double dist = boost::geometry::distance(point, poly); std::cout << "Distance between the point and the polygon is: " << dist << std::endl; return 0; }
内容的提问来源于stack exchange,提问作者mRQwerTY
相关产品推荐
相关产品推荐

