nvpro-samples / vk_raytrace

Ray tracing glTF scene with Vulkan
Apache License 2.0
550 stars 34 forks source link

Cant link with nvml.lib(nvml.dll) with VS2022 #25

Open pcarret opened 1 year ago

pcarret commented 1 year ago

Hello,

During compilation with VS2022 of vk_raytrace.exe I ended with an error I can't fix.

\vk_raytrace\out\build\x64-Debug\nvml.lib(nvml.dll) : error LNK2001: symbole externe non résolu __delayLoadHelper2

I tried to add

C:\Program Files\NVIDIA Corporation\NVSMI\nvml.dll
C:\Program Files\NVIDIA Corporation\NVSMI\nvml.lib

I have installed latest CUDA 12.2 https://developer.nvidia.com/gpu-deployment-kit says : The GPU Deployment Kit is part of the CUDA Toolkit, in versions 8 and later, and is no longer available as a separate download.

I do not know how to proceed

mklefrancois commented 1 year ago

Hi, there is something unusual in your log, the nvml.lib shouldn't show up in the build directory. Maybe you could try re-running CMake.

Open the solution and try compiling again.

Note: The nvml DLL is part of the driver and will be store in a path similar to this:

C:\Windows\System32\DriverStore\FileRepository\nv_dispig.inf_amd64_46b941c49f6a5e3e\nvml.dll
pcarret commented 1 year ago

Hi @mklefrancois ,

Thanks for your message and your help proposal I tried to clean buil, rebuild etc.. but nothing worked

I find out that delayimp.lib hold the missing __delayLoadHelper2 symbol So I tried to add these two lines but without any success

  target_link_libraries(${PROJNAME} debug  "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/lib/x64/delayimp.lib")
  target_link_libraries(${PROJNAME} optimized "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/lib/x64/delayimp.lib")

Is there any way to get the vk_raytrace exe directly and use it from command line ?

ynikanchyk commented 1 month ago

@pcarret Not sure where you tried to add target_link_libraries mentioned but for me this works fine:

diff --git a/CMakeLists.txt b/CMakeLists.txt                                                                                                                                                                                                index cd662c6..7684636 100644                                                                                                                                                                                                               --- a/CMakeLists.txt                                                                                                                                                                                                                        +++ b/CMakeLists.txt                                                                                                                                                                                                                        @@ -80,6 +80,7 @@ _add_project_definitions(${PROJNAME})                                                                                                                                                                                      # For NVML, the DLL is loaded by the application                                                                                                                                                                                            if(MSVC)                                                                                                                                                                                                                                      set_target_properties(${PROJNAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:nvml.dll")                                                                                                                                                           +  target_link_libraries(${PROJNAME} "delayimp.lib")                                                                                                                                                                                         endif()                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 #--------------------------------------------------------------------------------------------------