admin管理员组

文章数量:1417070

I'm facing a problem which I don't really understand when trying to use a GDExtension library in a new project, so I'm going to explain as detailed as possible what I think might be important. I thank you for reading all this and trying to help me.

I followed both GDExtension C++ example and mohsen zare's GDExtension tutorials and created a new node for Godot 4.3. This is my original project's folder structure:

WFC - GDExtension 4.3/
├── .godot/
├── demo/
├── GDExtension/
│   ├── godot-cpp/          # godot-cpp submodule
│   ├── src/                # My C++ source code
│   ├── .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

In order to compile my libraries I used scons -Q in GDExtension folder. When opening the Godot project, all works perfectly fine. This is my 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"

I wanted to make a GitHub repository with a workflow so I can build the library for Windows, Linux and macOS. This is the folder structure:

WaveFunctionCollapse-GodotAddon/
├── .github/
│   └── workflows/
│       └── build.yml
├── GDExtension/
│   ├── godot-cpp/          # godot-cpp submodule
│   ├── src/                # My C++ source code
│   ├── .gitmodules
│   └── SConstruct
├── addons/
│   └── wfc/
│       ├── demo/
│       ├── README.md
│       ├── plugin.cfg
│       └── wfc_generator2d.gdextension
├── media/
├── .gitignore
├── LICENSE
└── README.md

And this is my build.yml in workflows folder:

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/

With this, when I create a new version tag I generate the following zip:

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

This is my new 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"

And this is 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"

I've created a really simple wfc_generator2d.gd file so the editor doesn't warn me about the missing script:

@tool
extends EditorPlugin

func _enter_tree():
    pass

func _exit_tree():
    pass

When I create a new Godot 4.3 project and I add my "addons" folder, I find this error:

  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.

These are the things I've tried/checked:

  1. I went to my original project and replaced the library I made locally with the one generated by GitHub. That project still worked fine, so I assume the library is built correctly. Also tested changing from windows.debug.x86_64 to windows.x86_64 in .gdextension file and nothing was wrong with that.
  2. I've tried moving .gdextension file and the library outside addons folder. Also tried using relative paths, but none of that worked.

I've been desperately looking for information about this for a couple of days but I can't find anything useful for this problem. I don't know what could prevent Godot from detecting the GDExtension library even with correct paths, or if there are requirements I don't know about.

If someone knows what might be the issue, or at least has some idea that I can try and test, please let me know. I don't want this project to go into waste just because I can't share it with anyone due to this.

Thanks a lot!

本文标签: godot4Godot GDExtension Error quotNo library found for OSarchquot despite correct pathsStack Overflow