Fails to properly write Cmake to produce build the project. Crashes error undefined reference to `main'.
Project structure:
main.cpp
include
-- CUDA_wrappers.hpp
src
-- CUDA.cu
cmake_minimum_required(VERSION 3.8)
project(Mandelbrot_set)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp include/CUDA_wrappers.hpp src/CUDA.cu)
# LIBGD Package
find_package(GD REQUIRED)
include_directories(${GD_INCLUDE_DIR})
# CUDA Package
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
# Compile CU files
list( APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_20,code=sm_20; -std=c++11")
cuda_compile(CudaKernel src/CUDA.cu)
cuda_add_library(CudaKernels src/CUDA.cu)
# COMPILE AND LINK
cuda_add_executable(Mandelbrot_set $(SOURCE_FILES) CudaKernels)
target_link_libraries(Mandelbrot_set ${GD_LIBRARIES} ${CUDA_LIBRARIES})
In Cmake do not understand, I tried different options from the network.
CUDA sort works correctly, it sees my adapter, and correctly displays its characteristics.
In main.cpp and CUDA.cu included CUDA_wrappers.hpp. In CUDA_wrappers.hpp is declared a function that is defined in CUDA.cu. This function is called in main.cpp
If you need more details - misleading.
Replace with the following:
And if there are errors, please describe them in detail. - Breana_Leffl commented on June 8th 19 at 17:29
So the project seems to be gathered somehow. However when run crashes segmentation fault when calling the function, which is declared in CUDA_wrappers.hpp. It seems that the problem isn't solved. Well, at least it compiles CUDA code.
In the way that you suggest the comment above, the project also successfully gathered. But the problem is the same, segmentation fault when accessing function from CUDA_wrappers.hpp. - Gene commented on June 8th 19 at 17:32