You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux到Windows交叉编译Vulkan Loader出现大量Vulkan对象未定义引用

问题描述

我在Manjaro系统上,尝试通过mingw64交叉编译KhronosGroup官方的Vulkan-Loader源码,使用的cmake命令为:

x86_64-w64-mingw32-cmake -DVULKAN_HEADERS_INSTALL_DIR=/usr/x86_64-w64-mingw32/ -DVulkanRegistry_DIR=/usr/x86_64-w64-mingw32/share/vulkan/registry/ -DUSE_MASM=OFF ..

cmake配置输出如下:

-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found VulkanHeaders: /usr/x86_64-w64-mingw32/include  
-- Found VulkanRegistry: /usr/x86_64-w64-mingw32/share/vulkan/registry  
-- Detected Vulkan Version 1.2.182
-- Looking for secure_getenv
-- Looking for secure_getenv - not found
-- Looking for __secure_getenv
-- Looking for __secure_getenv - not found
CMake Warning at loader/CMakeLists.txt:27 (message):
  Using non-secure environmental lookups.  This loader will not properly
  disable environent variables when run with elevated permissions.


-- Found PkgConfig: /usr/bin/pkg-config (found version "1.7.3") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/flippers2652/Documents/Temp/Vulkan-Loader/build

执行make后出现大量Vulkan对象未定义引用的报错。

解决方案
  • 版本对齐:你使用的Vulkan-Loader源码版本必须和mingw前缀下安装的Vulkan-Headers版本完全一致。cmake输出显示当前检测到的Vulkan版本为1.2.182,如果你拉取的Vulkan-Loader版本高于该版本,新引入的Vulkan符号就会找不到定义。可以切换Vulkan-Loader的git标签到和Vulkan-Headers对应的版本,或者手动编译安装同版本的Vulkan-Headers到/usr/x86_64-w64-mingw32/目录下。
  • 补充cmake编译参数,调整后的完整cmake命令如下:
x86_64-w64-mingw32-cmake \
-DVULKAN_HEADERS_INSTALL_DIR=/usr/x86_64-w64-mingw32/ \
-DVulkanRegistry_DIR=/usr/x86_64-w64-mingw32/share/vulkan/registry/ \
-DUSE_MASM=OFF \
-DBUILD_STATIC_LOADER=OFF \
-DCMAKE_C_FLAGS="-D__VK_STRUCTURE_TYPE_FUTURE_EXTENSION_IGNORE" \
-DCMAKE_CXX_FLAGS="-D__VK_STRUCTURE_TYPE_FUTURE_EXTENSION_IGNORE" \
..

其中BUILD_STATIC_LOADER=OFF为默认值,指定生成动态库vulkan-1.dll,避免静态编译需要额外处理依赖;两个编译定义用于忽略版本不匹配导致的未来扩展结构声明报错。

  • 清理旧的构建缓存后重新编译:
rm -rf build/*
cd build
# 执行上述修改后的cmake命令
make -j$(nproc)
  • 确认依赖完整:提前安装mingw-w64-x86_64-gcc、mingw-w64-x86_64-pkg-config、mingw-w64-x86_64-vulkan-headers这些Manjaro源中的mingw交叉编译依赖包,避免工具链缺失组件。

内容的提问来源于stack exchange,提问作者the green penguin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.13 19:00:03