Godot 4.3 GDExtension路径正确仍提示‘未找到对应OS/架构库’
问题:Godot 4.3 GDExtension插件导入新项目时找不到库文件
我按照官方C++示例和第三方教程为Godot 4.3开发了一个WFC算法节点,原项目运行正常。
原项目结构与配置
原项目文件夹结构:
WFC - GDExtension 4.3/ ├── .godot/ ├── demo/ ├── GDExtension/ │ ├── godot-cpp/ # godot-cpp子模块 │ ├── src/ # 我的C++源代码 │ ├── .gdignore │ ├── .gitmodules │ ├── .sconsign.dblite │ └── SConstruct ├── .gitattributes ├── .gitignore ├── libwfc.windows.template_debug.x86_64.dll ├── libwfc.windows.template_debug.x86_64.exp ├── libwfc.windows.template_debug.x86_64.lib ├── project.godot └── wfc_generator2d.gdextension
原项目wfc_generator2d.gdextension配置:
[configuration] entry_symbol = "wfc_generator2d_library_init" compatibility_minimum = "4.3" [libraries] windows.debug.x86_64 = "res://libwfc.windows.template_debug.x86_64.dll"
分发仓库与构建配置
为跨平台分发,我创建了GitHub仓库并配置自动构建Workflow,仓库结构如下:
WaveFunctionCollapse-GodotAddon/ ├── .github/ │ └── workflows/ │ └── build.yml ├── GDExtension/ │ ├── godot-cpp/ # godot-cpp子模块 │ ├── src/ # 我的C++源代码 │ ├── .gitmodules │ └── SConstruct ├── addons/ │ └── wfc/ │ ├── demo/ │ ├── README.md │ ├── plugin.cfg │ └── wfc_generator2d.gdextension ├── media/ ├── .gitignore ├── LICENSE └── README.md
构建Workflow(build.yml)内容:
name: Build and Release on: push: tags: - "v*.*.*" jobs: build: name: Compile GDExtension for multiple platforms runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] include: - os: ubuntu-latest platform: linux artifact_name: libwfc.linux.x86_64.so cores: $(nproc) - os: windows-latest platform: windows artifact_name: libwfc.windows.x86_64.dll cores: 2 - os: macos-latest platform: macos artifact_name: libwfc.macos.x86_64.dylib cores: $(sysctl -n hw.logicalcpu) steps: - name: Checkout repository uses: actions/checkout@v4 with: submodules: recursive - name: Install SCons (Linux) if: matrix.os == 'ubuntu-latest' run: sudo apt update && sudo apt install -y scons - name: Install SCons (Windows) if: matrix.os == 'windows-latest' run: | choco install python --pre python -m pip install --upgrade pip pip install scons - name: Install SCons (macOS) if: matrix.os == 'macos-latest' run: brew install scons - name: Build GDExtension run: cd GDExtension && scons platform=${{ matrix.platform }} target=template_release -j${{ matrix.cores }} - name: Upload built library uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact_name }} path: addons/wfc/bin/${{ matrix.platform }} release: name: Package Release Files needs: [build] runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Download all compiled artifacts uses: actions/download-artifact@v4 - name: Prepare release folder run: | mkdir -p release/addons cp -r addons/wfc release/addons/ cp LICENSE release/addons/wfc/ - name: Move compiled libraries run: | mkdir -p release/addons/wfc/bin/windows mkdir -p release/addons/wfc/bin/linux mkdir -p release/addons/wfc/bin/macos mv libwfc.windows.x86_64.dll/* release/addons/wfc/bin/windows/ mv libwfc.linux.x86_64.so/* release/addons/wfc/bin/linux/ mv libwfc.macos.x86_64.dylib/* release/addons/wfc/bin/macos/ - name: Upload ZIP as artifact uses: actions/upload-artifact@v4 with: name: WaveFunctionCollapse-GodotAddon-${{ github.ref_name }} path: release/
打标签后生成的压缩包结构:
WaveFunctionCollapse-GodotAddon-vX.Y.Z.zip └── addons/ └── wfc/ ├── bin/ │ ├── linux/ │ │ └── libwfc.linux.x86_64.so │ ├── macos/ │ │ └── libwfc.macos.x86_64.dylib │ └── windows/ │ ├── libwfc.windows.x86_64.dll │ ├── libwfc.windows.x86_64.exp │ └── libwfc.windows.x86_64.lib ├── demo/ ├── LICENSE ├── plugin.cfg ├── README.md └── wfc_generator2d.gdextension
新的wfc_generator2d.gdextension配置:
[configuration] entry_symbol = "wfc_generator2d_library_init" compatibility_minimum = "4.3" [libraries] # Windows windows.x86_64 = "res://addons/wfc/bin/windows/libwfc.windows.x86_64.dll" # Linux linux.x86_64 = "res://addons/wfc/bin/linux/libwfc.linux.x86_64.so" # macOS macos.x86_64 = "res://addons/wfc/bin/macos/libwfc.macos.x86_64.dylib"
plugin.cfg配置:
[plugin] name="Wave Function Collapse (WFC)" description="Implementation of the WFC algorithm" author="Raul Medina Martinez" version="0.5.0" script="wfc_generator2d.gd"
wfc_generator2d.gd代码:
@tool extends EditorPlugin func _enter_tree(): pass func _exit_tree(): pass
错误信息
将插件导入新Godot 4.3项目时,出现以下错误:
core/extension/gdextension.cpp:1011 - No GDExtension library found for current OS and architecture (windows.x86_64) in configuration file: res://addons/wfc/wfc_generator2d.gdextension Failed loading resource: res://addons/wfc/wfc_generator2d.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
已尝试的排查步骤
- 将GitHub构建的库替换到原项目中,可正常运行;修改原项目的.gdextension配置为release路径也无问题。
- 尝试将.gdextension文件和库移出addons文件夹,使用相对路径,均无效。
请求帮忙分析问题原因或提供排查思路。
内容的提问来源于stack exchange,提问作者Rulerou69
相关产品推荐
相关产品推荐

