Vulkan 演示无法在 Nvidia Jetson TX2 上编译

Posted

技术标签:

【中文标题】Vulkan 演示无法在 Nvidia Jetson TX2 上编译【英文标题】:Vulkan demo does not compile on Nvidia Jetson TX2 【发布时间】:2017-09-28 02:49:16 【问题描述】:

我在这里从 LunarG 下载了 Vulkan SDK:

https://github.com/LunarG/VulkanTools/

我已经使用 BUILDvt.md 中的说明成功编译了它,并且有一个“vulkan”目录,其中包含 vulkan.h 和 vulkan.hpp 文件。我已经复制了整个 vulkan 目录 tino /usr/local/include 以便 gcc 可以找到它。

但是,当我进入 VulkanTools 中的 demos 目录并输入 gcc cube.h 时,我得到了这个:

nvidia@tegra-ubuntu:~/code/VulkanTools/demos$ gcc cube.c
/tmp/ccbouT30.o: In function `vec3_len':
cube.c:(.text+0x258): undefined reference to `sqrtf'
/tmp/ccbouT30.o: In function `mat4x4_rotate':
cube.c:(.text+0xa38): undefined reference to `sinf'
cube.c:(.text+0xa44): undefined reference to `cosf'
/tmp/ccbouT30.o: In function `mat4x4_perspective':
cube.c:(.text+0xbe4): undefined reference to `tan'
/tmp/ccbouT30.o: In function `demo_flush_init_cmd':
cube.c:(.text+0x15ac): undefined reference to `vkEndCommandBuffer'
cube.c:(.text+0x160c): undefined reference to `vkCreateFence'
cube.c:(.text+0x169c): undefined reference to `vkQueueSubmit'
cube.c:(.text+0x16f0): undefined reference to `vkWaitForFences'
cube.c:(.text+0x174c): undefined reference to `vkFreeCommandBuffers'
cube.c:(.text+0x1760): undefined reference to `vkDestroyFence'
/tmp/ccbouT30.o: In function `demo_set_image_layout':
cube.c:(.text+0x1940): undefined reference to `vkCmdPipelineBarrier'
/tmp/ccbouT30.o: In function `demo_draw_build_cmd':
cube.c:(.text+0x1a78): undefined reference to `vkBeginCommandBuffer'
cube.c:(.text+0x1ac0): undefined reference to `vkCmdBeginRenderPass'
cube.c:(.text+0x1ad8): undefined reference to `vkCmdBindPipeline'
cube.c:(.text+0x1b30): undefined reference to `vkCmdBindDescriptorSets'
cube.c:(.text+0x1b84): undefined reference to `vkCmdSetViewport'
cube.c:(.text+0x1bcc): undefined reference to `vkCmdSetScissor'
cube.c:(.text+0x1be4): undefined reference to `vkCmdDraw'
cube.c:(.text+0x1bec): undefined reference to `vkCmdEndRenderPass'
cube.c:(.text+0x1cc8): undefined reference to `vkCmdPipelineBarrier'
cube.c:(.text+0x1cd0): undefined reference to `vkEndCommandBuffer'
/tmp/ccbouT30.o: In function `demo_build_image_ownership_cmd':
cube.c:(.text+0x1dac): undefined reference to `vkBeginCommandBuffer'
cube.c:(.text+0x1ec8): undefined reference to `vkCmdPipelineBarrier'
cube.c:(.text+0x1ef0): undefined reference to `vkEndCommandBuffer'
/tmp/ccbouT30.o: In function `demo_update_data_buffer':
cube.c:(.text+0x204c): undefined reference to `vkWaitForFences'
cube.c:(.text+0x20a0): undefined reference to `vkMapMemory'
cube.c:(.text+0x2124): undefined reference to `vkUnmapMemory'
/tmp/ccbouT30.o: In function `demo_draw':
cube.c:(.text+0x2778): undefined reference to `vkWaitForFences'
cube.c:(.text+0x27b0): undefined reference to `vkResetFences'
cube.c:(.text+0x29cc): undefined reference to `vkResetFences'
cube.c:(.text+0x2a18): undefined reference to `vkQueueSubmit'
cube.c:(.text+0x2b0c): undefined reference to `vkQueueSubmit'
/tmp/ccbouT30.o: In function `demo_prepare_buffers':
cube.c:(.text+0x3388): undefined reference to `vkWaitForFences'
cube.c:(.text+0x364c): undefined reference to `vkCreateImageView'
cube.c:(.text+0x36c4): undefined reference to `vkCreateFence'
/tmp/ccbouT30.o: In function `demo_prepare_depth':
cube.c:(.text+0x391c): undefined reference to `vkCreateImage'
cube.c:(.text+0x3974): undefined reference to `vkGetImageMemoryRequirements'
cube.c:(.text+0x3a44): undefined reference to `vkAllocateMemory'
cube.c:(.text+0x3aa0): undefined reference to `vkBindImageMemory'
cube.c:(.text+0x3b08): undefined reference to `vkCreateImageView'
/tmp/ccbouT30.o: In function `demo_prepare_texture_image':
cube.c:(.text+0x3efc): undefined reference to `vkCreateImage'
cube.c:(.text+0x3f54): undefined reference to `vkGetImageMemoryRequirements'
cube.c:(.text+0x3ff4): undefined reference to `vkAllocateMemory'
cube.c:(.text+0x4050): undefined reference to `vkBindImageMemory'
cube.c:(.text+0x40d0): undefined reference to `vkGetImageSubresourceLayout'
cube.c:(.text+0x4104): undefined reference to `vkMapMemory'
cube.c:(.text+0x41b4): undefined reference to `vkUnmapMemory'
/tmp/ccbouT30.o: In function `demo_destroy_texture_image':
cube.c:(.text+0x421c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x423c): undefined reference to `vkDestroyImage'
/tmp/ccbouT30.o: In function `demo_prepare_textures':
cube.c:(.text+0x4288): undefined reference to `vkGetPhysicalDeviceFormatProperties'
cube.c:(.text+0x4550): undefined reference to `vkCmdCopyImage'
cube.c:(.text+0x46e0): undefined reference to `vkCreateSampler'
cube.c:(.text+0x477c): undefined reference to `vkCreateImageView'
/tmp/ccbouT30.o: In function `demo_prepare_cube_data_buffers':
cube.c:(.text+0x4a68): undefined reference to `vkCreateBuffer'
cube.c:(.text+0x4adc): undefined reference to `vkGetBufferMemoryRequirements'
cube.c:(.text+0x4b88): undefined reference to `vkAllocateMemory'
cube.c:(.text+0x4c08): undefined reference to `vkMapMemory'
cube.c:(.text+0x4c94): undefined reference to `vkUnmapMemory'
cube.c:(.text+0x4cf8): undefined reference to `vkBindBufferMemory'
/tmp/ccbouT30.o: In function `demo_prepare_descriptor_layout':
cube.c:(.text+0x4e10): undefined reference to `vkCreateDescriptorSetLayout'
cube.c:(.text+0x4ea0): undefined reference to `vkCreatePipelineLayout'
/tmp/ccbouT30.o: In function `demo_prepare_render_pass':
cube.c:(.text+0x5058): undefined reference to `vkCreateRenderPass'
/tmp/ccbouT30.o: In function `demo_prepare_shader_module':
cube.c:(.text+0x511c): undefined reference to `vkCreateShaderModule'
/tmp/ccbouT30.o: In function `demo_prepare_pipeline':
cube.c:(.text+0x56b0): undefined reference to `vkCreatePipelineCache'
cube.c:(.text+0x5778): undefined reference to `vkCreateGraphicsPipelines'
cube.c:(.text+0x57cc): undefined reference to `vkDestroyShaderModule'
cube.c:(.text+0x57ec): undefined reference to `vkDestroyShaderModule'
/tmp/ccbouT30.o: In function `demo_prepare_descriptor_pool':
cube.c:(.text+0x58bc): undefined reference to `vkCreateDescriptorPool'
/tmp/ccbouT30.o: In function `demo_prepare_descriptor_set':
cube.c:(.text+0x5b00): undefined reference to `vkAllocateDescriptorSets'
cube.c:(.text+0x5bcc): undefined reference to `vkUpdateDescriptorSets'
/tmp/ccbouT30.o: In function `demo_prepare_framebuffers':
cube.c:(.text+0x5d1c): undefined reference to `vkCreateFramebuffer'
/tmp/ccbouT30.o: In function `demo_prepare':
cube.c:(.text+0x5e00): undefined reference to `vkCreateCommandPool'
cube.c:(.text+0x5e7c): undefined reference to `vkAllocateCommandBuffers'
cube.c:(.text+0x5ed4): undefined reference to `vkBeginCommandBuffer'
cube.c:(.text+0x5f88): undefined reference to `vkAllocateCommandBuffers'
cube.c:(.text+0x6030): undefined reference to `vkCreateCommandPool'
cube.c:(.text+0x60d0): undefined reference to `vkAllocateCommandBuffers'
/tmp/ccbouT30.o: In function `demo_cleanup':
cube.c:(.text+0x623c): undefined reference to `vkDeviceWaitIdle'
cube.c:(.text+0x627c): undefined reference to `vkWaitForFences'
cube.c:(.text+0x62ac): undefined reference to `vkDestroyFence'
cube.c:(.text+0x62d4): undefined reference to `vkDestroySemaphore'
cube.c:(.text+0x62fc): undefined reference to `vkDestroySemaphore'
cube.c:(.text+0x6334): undefined reference to `vkDestroySemaphore'
cube.c:(.text+0x6390): undefined reference to `vkDestroyFramebuffer'
cube.c:(.text+0x63d0): undefined reference to `vkDestroyDescriptorPool'
cube.c:(.text+0x63f0): undefined reference to `vkDestroyPipeline'
cube.c:(.text+0x6410): undefined reference to `vkDestroyPipelineCache'
cube.c:(.text+0x6430): undefined reference to `vkDestroyRenderPass'
cube.c:(.text+0x6450): undefined reference to `vkDestroyPipelineLayout'
cube.c:(.text+0x6470): undefined reference to `vkDestroyDescriptorSetLayout'
cube.c:(.text+0x64b4): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x64f0): undefined reference to `vkDestroyImage'
cube.c:(.text+0x652c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6568): undefined reference to `vkDestroySampler'
cube.c:(.text+0x65c8): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x65e8): undefined reference to `vkDestroyImage'
cube.c:(.text+0x6608): undefined reference to `vkFreeMemory'
cube.c:(.text+0x664c): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6694): undefined reference to `vkFreeCommandBuffers'
cube.c:(.text+0x66d0): undefined reference to `vkDestroyBuffer'
cube.c:(.text+0x670c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6748): undefined reference to `vkDestroyFence'
cube.c:(.text+0x67a0): undefined reference to `vkDestroyCommandPool'
cube.c:(.text+0x67d0): undefined reference to `vkDestroyCommandPool'
cube.c:(.text+0x67dc): undefined reference to `vkDeviceWaitIdle'
cube.c:(.text+0x67ec): undefined reference to `vkDestroyDevice'
cube.c:(.text+0x6844): undefined reference to `vkDestroySurfaceKHR'
cube.c:(.text+0x6854): undefined reference to `vkDestroyInstance'
/tmp/ccbouT30.o: In function `demo_resize':
cube.c:(.text+0x6898): undefined reference to `vkDeviceWaitIdle'
cube.c:(.text+0x68dc): undefined reference to `vkDestroyFramebuffer'
cube.c:(.text+0x691c): undefined reference to `vkDestroyDescriptorPool'
cube.c:(.text+0x693c): undefined reference to `vkDestroyPipeline'
cube.c:(.text+0x695c): undefined reference to `vkDestroyPipelineCache'
cube.c:(.text+0x697c): undefined reference to `vkDestroyRenderPass'
cube.c:(.text+0x699c): undefined reference to `vkDestroyPipelineLayout'
cube.c:(.text+0x69bc): undefined reference to `vkDestroyDescriptorSetLayout'
cube.c:(.text+0x6a00): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6a3c): undefined reference to `vkDestroyImage'
cube.c:(.text+0x6a78): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6ab4): undefined reference to `vkDestroySampler'
cube.c:(.text+0x6aec): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6b0c): undefined reference to `vkDestroyImage'
cube.c:(.text+0x6b2c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6b70): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6bb8): undefined reference to `vkFreeCommandBuffers'
cube.c:(.text+0x6bf4): undefined reference to `vkDestroyBuffer'
cube.c:(.text+0x6c30): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6c6c): undefined reference to `vkDestroyFence'
cube.c:(.text+0x6cac): undefined reference to `vkDestroyCommandPool'
cube.c:(.text+0x6cdc): undefined reference to `vkDestroyCommandPool'
/tmp/ccbouT30.o: In function `demo_init_vk':
cube.c:(.text+0x6ea4): undefined reference to `vkEnumerateInstanceLayerProperties'
cube.c:(.text+0x6f18): undefined reference to `vkEnumerateInstanceLayerProperties'
cube.c:(.text+0x7084): undefined reference to `vkEnumerateInstanceExtensionProperties'
cube.c:(.text+0x70f8): undefined reference to `vkEnumerateInstanceExtensionProperties'
cube.c:(.text+0x73d0): undefined reference to `vkCreateInstance'
cube.c:(.text+0x7478): undefined reference to `vkEnumeratePhysicalDevices'
cube.c:(.text+0x74ec): undefined reference to `vkEnumeratePhysicalDevices'
cube.c:(.text+0x7578): undefined reference to `vkEnumerateDeviceExtensionProperties'
cube.c:(.text+0x761c): undefined reference to `vkEnumerateDeviceExtensionProperties'
cube.c:(.text+0x7998): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x79c0): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7a50): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7b94): undefined reference to `vkGetPhysicalDeviceProperties'
cube.c:(.text+0x7bb4): undefined reference to `vkGetPhysicalDeviceQueueFamilyProperties'
cube.c:(.text+0x7c38): undefined reference to `vkGetPhysicalDeviceQueueFamilyProperties'
cube.c:(.text+0x7c48): undefined reference to `vkGetPhysicalDeviceFeatures'
cube.c:(.text+0x7c64): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7cc0): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7d1c): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7d78): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7dd4): undefined reference to `vkGetInstanceProcAddr'
/tmp/ccbouT30.o: In function `demo_create_device':
cube.c:(.text+0x7f54): undefined reference to `vkCreateDevice'
/tmp/ccbouT30.o: In function `demo_init_vk_swapchain':
cube.c:(.text+0x823c): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x82e4): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x838c): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x8434): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x84dc): undefined reference to `vkGetInstanceProcAddr'
/tmp/ccbouT30.o:cube.c:(.text+0x8594): more undefined references to `vkGetInstanceProcAddr' follow
/tmp/ccbouT30.o: In function `demo_init_vk_swapchain':
cube.c:(.text+0x86dc): undefined reference to `vkGetDeviceQueue'
cube.c:(.text+0x8730): undefined reference to `vkGetDeviceQueue'
cube.c:(.text+0x8908): undefined reference to `vkCreateFence'
cube.c:(.text+0x8970): undefined reference to `vkCreateSemaphore'
cube.c:(.text+0x89d8): undefined reference to `vkCreateSemaphore'
cube.c:(.text+0x8a50): undefined reference to `vkCreateSemaphore'
cube.c:(.text+0x8ac0): undefined reference to `vkGetPhysicalDeviceMemoryProperties'
collect2: error: ld returned 1 exit status
nvidia@tegra-ubuntu:~/code/VulkanTools/demos$

这是驱动问题吗?还是我的编译器或包含文件设置错误?

【问题讨论】:

您可能没有安装这些库。您还需要与加载程序链接。 @tambre:我在哪里可以找到这些库?你能给我一两个关于它们长什么样的提示吗? Apols对此非常陌生。您是指 Vulkan 驱动程序吗? 您没有与驱动程序链接 (lol) - 当您调用 Vulkan 函数时,Vulkan 加载程序会为驱动程序中的函数加载适当的地址。在 Windows 上,Vulkan 加载程序是 vulkan-1.lib。考虑到您是从源代码构建的,它可能也是在某个地方构建的 - 我不知道 apt install libvulkan-dev 的详细信息,而且 Vulkan SDK 对我来说已经足够好了。 其实我想我是在 /usr/lib/aarch64-linux-gnu/libvulkan 找到的 @ThomasBrowne 卸载 libvulkan1libvulkan-dev。然后将您的头文件版本复制到include/vulkan/ 和系统库所在的编译库中(理想情况下,使用ln -sf 遵循类似的方案,但只有libvulkan.so 也应该没问题)。这里没有诀窍。关键是*.soPATH 中,因此应用程序可以看到它,因此您不必在编译时声明-Lpath。编辑:实际上,为了形式起见,我会做出某种回答。 【参考方案1】:

您没有使用 -lvulkan 进行编译,因此缺少列出的 Vulkan 命令的定义。就这么简单。

在典型的 Linux 发行版上,您需要 libvulkan1(具有 libvulkan.so 和朋友)和 libvulkan-dev 包(具有 vulkan.h)。对于开发,您需要其他东西,例如验证层和glslangValidator(不确定它们是否已打包)。这些软件包可能不存在,或者对于您的发行版的口味来说太过时了。

另一个选择是LunarG SDK。它将所有东西放在一个地方,并且经常更新。但不会自动安装到系统位置/PATH。此外,它仅(在撰写本文时)为 x86_64 提供。

最后的选择是自己编译(就像你做的那样)。作为 SDK,它不会自动安装到系统位置/PATH。所以这需要处理并确保您没有在libvulkan1libvulkan-dev 中使用意外预安装的版本。

【讨论】:

你还需要-lm来获取sqrtfsinf等同样缺失的东西。 是的,我正在运行 aarch64(Nvidia Jetson TX2)因此编译。主要问题似乎是 VulkanTools 目录树非常庞大,并且没有创建 rpm 或 dpkg 来将所有正确的东西粘贴到正确的位置。我猜是根据您上面的建议反复试验。从 VulkanTools/include 和 build/install/bin 开始,它似乎包含您提到的 glslangValidator。 VulkanTools 下实际上有 462 个目录,我不能将它们全部放在路径中。 Vulkan 肯定不会浪费任何时间让您进入它的学习曲线;-)【参考方案2】:

我在尝试为 NVIDIA Jetson TX2 编译 https://github.com/SaschaWillems/Vulkan 时遇到了类似的问题。

我可以通过创建从 /usr/lib/aarch64-linux-gnu/ 到项目 libvulkan.so 的符号链接来解决这个问题

基本上:

$ cd <PATH_TO_LIBVULKAN_IN_PROJECT>
$ ln -s /usr/lib/aarch64-linux-gnu/libvulkan.so.1 libvulkan.so

如果您随后在目录中执行“ls -lt”,您应该会看到如下内容:

$ ls -lt
libvulkan.so -> /usr/lib/aarch64-linux-gnu/libvulkan.so.1 

【讨论】:

以上是关于Vulkan 演示无法在 Nvidia Jetson TX2 上编译的主要内容,如果未能解决你的问题,请参考以下文章

VULKAN学习资料收集

Vulkan 学习资料汇总

我的NVIDIA开发者之旅——作为一名初学者,我是如何开启 NVIDIA Jetson Nano 开发的

至于 vulkan,GeForce RTX 3090 的 GPU 驱动程序不起作用

无法将 Cuda 内存导入 Vulkan

Android Studio Emulator:无法添加库 vulkan-1.dll:失败