Hi,
using visual studio toolchain (Windows 10) with a CMakeLists.txt inside the JetBrain CLion-Nova IDE I am able to compile but not link onto the cuCtxSynchronize and I am getting an error
====================[ Build | SystemProgrammingCuda | Debug-Visual Studio ]=====
"C:\Users\Frederic\AppData\Local\Programs\CLion Nova\bin\cmake\win\x64\bin\cmake.exe" --build C:\Users\Frederic\OneDrive\UVPD-Perpignan\SourceCodes\CLionProjects\SystemProgrammingCuda\cmake-build-debug-visual-studio --target SystemProgrammingCuda -j 6
[1/1] Linking CUDA executable SystemProgrammingCuda.exe
FAILED: SystemProgrammingCuda.exe
cmd.exe /C "cd . && "C:\Users\Frederic\AppData\Local\Programs\CLion Nova\bin\cmake\win\x64\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\SystemProgrammingCuda.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MIB055~1\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo CMakeFiles\SystemProgrammingCuda.dir\main.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\timming.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\cmdLine.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\get_deviceQuery_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\get_systemQuery_cpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\deviceTools_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\Sockets.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\carte_mesh_3D.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\dataDeviceManag.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\resmap_Sizes.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\common_Helpr_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\common_krnl_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\global.cu.obj CMakeFiles\SystemProgrammingCuda.dir\cmake_device_link.obj /out:SystemProgrammingCuda.exe /implib:SystemProgrammingCuda.lib /pdb:SystemProgrammingCuda.pdb /version:0.0 /debug /INCREMENTAL "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cufft.lib" cudadevrt.lib cudart_static.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/lib/x64" && cd ."
LINK Pass 1: command "C:\PROGRA~2\MIB055~1\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo CMakeFiles\SystemProgrammingCuda.dir\main.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\timming.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\cmdLine.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\get_deviceQuery_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\get_systemQuery_cpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\utils\deviceTools_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\Sockets.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\carte_mesh_3D.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\dataDeviceManag.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\resmap_Sizes.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\common_Helpr_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\src\common_krnl_gpu.cu.obj CMakeFiles\SystemProgrammingCuda.dir\global.cu.obj CMakeFiles\SystemProgrammingCuda.dir\cmake_device_link.obj /out:SystemProgrammingCuda.exe /implib:SystemProgrammingCuda.lib /pdb:SystemProgrammingCuda.pdb /version:0.0 /debug /INCREMENTAL C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cufft.lib cudadevrt.lib cudart_static.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/lib/x64 /MANIFEST /MANIFESTFILE:CMakeFiles\SystemProgrammingCuda.dir/intermediate.manifest CMakeFiles\SystemProgrammingCuda.dir/manifest.res" failed (exit code 1120) with the following output:
Creating library SystemProgrammingCuda.lib and object SystemProgrammingCuda.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
main.cu.obj : error LNK2019: unresolved external symbol cuCtxSynchronize referenced in function main
SystemProgrammingCuda.exe : fatal error LNK1120: 1 unresolved externals
ninja: build stopped: subcommand failed.
as if I did I forgot to link onto a library. I have included
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cuda_device_runtime_api.h>
#include <cufftXt.h>
#include <cufft.h>
#include <cuda.h>
and I am trying to link to the cufft library in the CMakeLists.txt this way (cufftXt link does not work but I am
not sure that it is really needed):
set(FIND_CUDA_BIN_PATHS C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v12.1/bin/)
set(FIND_CUFFT_PATHS C:/Program Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v12.2)
set(CMAKE_CUDA_HOST_COMPILER "${FIND_CUDA_BIN_PATHS}")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -fPIC --ptxas-options=-v")
find_path(CUFFT_INCLUDE_DIR cufft.h PATH_SUFFIXES include PATHS ${FIND_CUFFT_PATHS})
find_path(CUFFTXT_INCLUDE_DIR cufftXt.h PATH_SUFFIXES include PATHS ${FIND_CUFFTXT_PATHS})
find_library(CUFFT_LIBRARY NAMES cufft PATH_SUFFIXES lib/x64 PATHS ${FIND_CUFFT_PATHS})
include_directories(${CUFFT_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${CUFFT_LIBRARY})
How to make the linker see cuCtxSynchroze() which I use in almost all my kernel calls.
Have I forgotten something or missing a library link somewhere ?
Thanks,
F.