nvpro-samples / vk_raytracing_tutorial_KHR

Ray tracing examples and tutorials using VK_KHR_ray_tracing
Apache License 2.0
1.34k stars 142 forks source link

CMakeLists linker is missing libdl #24

Open chrisdonlan opened 3 years ago

chrisdonlan commented 3 years ago
cd vk_raytracing_tutorial_KHR
mkdir build
cd build
cmake ..
make -j 40

Compiles shared sources successfully, fails during the linking step:

[100%] Linking CXX executable /home/chris/ray-tracing/bin_x64/vk_ray_tracing__advance_NV.exe
/usr/bin/ld: CMakeFiles/vk_ray_tracing_anyhit_NV.dir/hello_vulkan.cpp.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /usr/lib64/libdl.so.2: error adding symbols: DSO missing from command line

libdl is installed via glibc-devel

Installed Packages
glibc-devel.x86_64  2.32-1.fc33

I think that the fix is going to be adding:

-ldl 

Somewhere in a CMakeLists target_link_library; I'll try that, and post the fix (if I get it working).

ghost commented 1 year ago

Any idea on the fix so far? I've been unable to start the ray tracing tutorial.

NBickford-NV commented 1 year ago

Hi @DannyLeWasTaken! I've just had a go at building this on Ubuntu 20.04 and CMake 3.24.1, but couldn't reproduce it (i.e. it seemed to link successfully) - here's the complete script I used to download and build:

git clone --recursive https://github.com/nvpro-samples/nvpro_core.git
git clone https://github.com/nvpro-samples/vk_raytracing_tutorial_KHR.git
cd vk_raytracing_tutorial_KHR && mkdir build && cd build
cmake ..
make -j

Running make VERBOSE=1, it looks like the linker command line now includes -ldl near the end (possibly from glfw, though I'm not 100% sure yet):

[ 25%] Linking CXX executable [omitted]/bin_x64/Release/vk_ray_tracing__advance_KHR_app
cd [omitted]/vk_raytracing_tutorial_KHR/build/ray_tracing__advance && /usr/bin/cmake -E cmake_link_script CMakeFiles/vk_ray_tracing__advance_KHR.dir/link.txt --verbose=1
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/vk_ray_tracing__advance_KHR.dir/hello_vulkan.cpp.o CMakeFiles/vk_ray_tracing__advance_KHR.dir/main.cpp.o CMakeFiles/vk_ray_tracing__advance_KHR.dir/offscreen.cpp.o CMakeFiles/vk_ray_tracing__advance_KHR.dir/raytrace.cpp.o "CMakeFiles/vk_ray_tracing__advance_KHR.dir/[omitted]/nvpro_core/nvp/perproject_globals.cpp.o" "CMakeFiles/vk_ray_tracing__advance_KHR.dir/mnt/c/Users/nbickford/Documents/GitHub/nvpro-samples-test/nvpro_core/nvvk/nsight_aftermath_vk.cpp.o" CMakeFiles/vk_ray_tracing__advance_KHR.dir/__/common/obj_loader.cpp.o -o [omitted]/bin_x64/Release/vk_ray_tracing__advance_KHR_app  /usr/lib/x86_64-linux-gnu/libvulkan.so -lXxf86vm [omitted]/bin_x64/Release/libnvpro_core_vk.a /usr/lib/x86_64-linux-gnu/libvulkan.so /usr/lib/x86_64-linux-gnu/libvulkan.so -lXxf86vm /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libXext.so ../nvpro_core/third_party/glfw/src/libglfw3.a /usr/lib/x86_64-linux-gnu/librt.so -lm -ldl /usr/lib/x86_64-linux-gnu/libX11.so -lpthread ../nvpro_core/third_party/libimgui.a

My best guess is that the mechanism that's adding the -ldl here is breaking somehow. Could you post what OS and compiler versions you're using, if possible? I can set up a clean OS image and try to reproduce this build issue there.

Thanks!

nvmheyer commented 1 year ago

@chrisdonlan what build environment are you using?

I'm confused as to which sample you're attempting to build. The error message posted indicates you're attempting to build https://github.com/nvpro-samples/vk_raytracing_tutorial_NV which is deprecated.

Please try building the KHR sample instead.

ghost commented 1 year ago

@NeilBickford-NV Ah, the error seemed to lie in the fact that my Windows 10 device had a space in it's user file. As such, the program ended up searching for directories in "Le" user folder which did not exist when the user folder existed in "Danny Le". I kinda ended up borking my system trying to arrogantly to fix the problem by changing my user folder name so I sadly don't have the logs with me any more. Sorry!

NBickford-NV commented 1 year ago

@DannyLeWasTaken - ah, thanks, good to know! Best of luck with the system recovery process!

NBickford-NV commented 1 year ago

@DannyLeWasTaken Oh, one more question: since you mentioned using a Windows 10 device, but also libdl, are you using WSL2? If so, it might be easier to test running these samples under Windows directly; note that while we support building and running on both Windows and native Linux, and building on WSL2, WSL2 does not yet support Vulkan hardware acceleration.