Skip to content
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

Unresolved external symbols #50

Closed
casool opened this issue Mar 6, 2024 · 7 comments
Closed

Unresolved external symbols #50

casool opened this issue Mar 6, 2024 · 7 comments

Comments

@casool
Copy link

casool commented Mar 6, 2024

I'm unable to build my project upon including this create device line in my code:

#include <nvrhi/vulkan.h>
...
nvrhi::vulkan::createDevice(deviceDesc);
...
1>main.cpp
1>nvrhi_vk.lib(vulkan-resource-bindings.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-commandlist.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-state-tracking.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-graphics.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-compute.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-meshlets.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-raytracing.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-staging-texture.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-buffer.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-shader.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-queries.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-device.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-queue.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-allocator.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)
1>nvrhi_vk.lib(vulkan-texture.obj) : error LNK2001: unresolved external symbol "class vk::DispatchLoaderDynamic vk::defaultDispatchLoaderDynamic" (?defaultDispatchLoaderDynamic@vk@@3VDispatchLoaderDynamic@1@A)

My top level CMakeLists:

...
# Dependencies
find_package(Vulkan REQUIRED)
add_subdirectory(Dependencies)

if (VULKAN_FOUND)
    include_directories(${Vulkan_INCLUDE_DIRS})
    target_link_libraries (${PROJECT_NAME} ${Vulkan_LIBRARIES} Dependencies)
endif (VULKAN_FOUND)
...

Dependencies/CMakeLists:

...
set(NVRHI_BUILD_SHARED OFF CACHE BOOL "" FORCE)

set(NVRHI_WITH_DX11 OFF CACHE BOOL "" FORCE)
set(NVRHI_WITH_DX12 OFF CACHE BOOL "" FORCE)
set(NVRHI_WITH_VULKAN ON CACHE BOOL "" FORCE)

add_subdirectory(nvrhi)
target_link_libraries(Dependencies INTERFACE nvrhi)
target_link_libraries(Dependencies INTERFACE nvrhi_vk)
...
@pmrochen
Copy link

pmrochen commented Mar 6, 2024

You have to declare an instance of vk::DispatchLoaderDynamic somewhere in your .cpp file.

The simplest way is to use helper macro:

//...
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE;
//...

@casool
Copy link
Author

casool commented Mar 6, 2024

You have to declare an instance of vk::DispatchLoaderDynamic somewhere in your .cpp file.

The simplest way is to use helper macro:

//...
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE;
//...

Does nvrhi require me to use the Vulkan C++ bindings? Also, isn't this only necessary if you're building a shared library? It seems nvrhi should automatically do it for you:

VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE

@pmrochen
Copy link

pmrochen commented Mar 7, 2024

Unfortunately, by defining:

#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1

nvrhi forces you to use C++ dynamic dispatcher, regardless you're building a shared library or not. In reality, it's not always the case, and you should have the ability to enable/disable dynamic dispatcher independently of shared library setting. Also, you should have the ability to issue VULKAN_HPP_DEFAULT_DISPATCHER.init() in your code, your way. It looks like we need two new configuration macros to cope with this issue.

@apanteleev
Copy link
Contributor

NVRHI will create its own dynamic dispatcher when it's built as a shared library / DLL.
I recently suggested adding an option to do the same when it's built as a static library, with some caveats; see #48

@casool
Copy link
Author

casool commented Mar 12, 2024

Unfortunately, by defining:

#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1

nvrhi forces you to use C++ dynamic dispatcher, regardless you're building a shared library or not. In reality, it's not always the case, and you should have the ability to enable/disable dynamic dispatcher independently of shared library setting. Also, you should have the ability to issue VULKAN_HPP_DEFAULT_DISPATCHER.init() in your code, your way. It looks like we need two new configuration macros to cope with this issue.

So is the solution to include the Vulkan hpp header in my project?

@apanteleev
Copy link
Contributor

Include the vulkan.hpp header and define VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE somewhere at global scope. See https://github.com/NVIDIAGameWorks/donut/blob/main/src/app/vulkan/DeviceManager_VK.cpp for an example.

@casool
Copy link
Author

casool commented Mar 12, 2024

Thanks!

@casool casool closed this as completed Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants