-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking nvrhi and nvrhi_vk to a library produces errors when linking to an executable afterwards #48
Comments
Bonus code : how I include the headers In my libraryVulkanContext.h #include <nvrhi/nvrhi.h>
#include <VkBootstrap.h> VulkanContext.cpp #include <Renderer/VulkanContext.h>
#include <nvrhi/vulkan.h>
#include <nvrhi/validation.h>
#include <Logging/Logging.h>
#define GLFW_INCLUDE_VULKAN // Might not be needed, or maybe use GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> In my executableTestContext.cpp #include <Renderer/VulkanContext.h> |
That's the problem. When linking NVRHI statically, some other part of the final linked program needs to define the Vulkan dynamic loader that will be used by NVRHI. When NVRHI is built as a DLL, the loader is defined inside the library. See https://github.com/NVIDIAGameWorks/donut/blob/main/src/app/vulkan/DeviceManager_VK.cpp and search for "dynamic" for an example. (Also, maybe it makes sense to add a CMake option to let NVRHI define the loader even in static linking mode) |
Makes sense, I think I'll go towards the shared dll route.
What do you mean by that though? Thanks a lot for the quick answer! |
I mean that I could add an option to change the way NVRHI is built in the static library mode. With the new option enabled, it would define the dynamic loader inside the library so that you won't have to. One downside here is that the application may need to use the dynamic loader before NVRHI is initialized, which would not be possible. |
Ah I see. I'm not experienced enough to speak on the matter, I have to admit. |
Hi,
I followed the instruction to install nvrhi as a submodule and I'm trying to use it with cmake.
I use
To include the project, then later on I link it to one of my libraries.
This is what it currently looks like. At some point I had nvrhi first, then I used
Vulkan::Vulkan
instead ofVulkan-Headers
, etc. But in the end the target Renderer always built itself correctly.Now if I link Renderer to another target and use one of the functions I get a link error LNK2001 (The compiler can't find vulkan-hpp's dynamic loader).
I tried linking nvrhi to said target, I tried linking vulkan, didn't work. Note that I use vk-boostrap to speed up vulkan instance creation but even if I remove it it still doesn't work.
Does anyone have an idea as why it doesn't work ? Maybe I'm just dumb and forgot how c++ libraries and linking work.
The text was updated successfully, but these errors were encountered: