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

How to use this? Sample Project? #69

Open
ahrbe1 opened this issue Sep 7, 2024 · 1 comment
Open

How to use this? Sample Project? #69

ahrbe1 opened this issue Sep 7, 2024 · 1 comment

Comments

@ahrbe1
Copy link

ahrbe1 commented Sep 7, 2024

So I am pretty new to Godot, though I do know CMake and C++ pretty well. I went through the official gdextension docs for scons, and then later found this project. I managed to get this project building out of the box, no problem. The question I have is where does this go in relation to my Godot project files? The setup instructions in the readme don't quite tell me that part (or at least I missed it).

After inspecting https://github.com/nathanfranke/gdextension, I made some guesses and attempted to structure things like the following:

.
├── CHANGELOG.md
├── CMakeLists.txt
├── CMakePresets.json
├── MyProject/
|   └── addons/
│   |   └── MyPlugin/
│   |       ├── MyPlugin.gdextension
│   |       ├── icons/
│   |       │   └── Example.svg
│   |       └── lib/
│   |           └── Windows-AMD64
│   |               └── MyPlugin.dll
│   ├── icon.svg
│   ├── icon.svg.import
│   ├── icons/
│   ├── main.tscn
│   └── project.godot
├── LICENSE.md
├── README.md
├── build/
├── cmake/
├── extern/
│   └── godot-cpp/
├── src/
├── support_files/
└── templates/

By using the following build commands:

// x64 Native Tools Command Prompt for Visual Studio 2022
> cmake -DCMAKE_BUILD_TYPE=Release -B build -DCMAKE_INSTALL_PREFIX=MyProject/addons/ -G Ninja
> ninja -C build
> ninja -C build install

Everything compiles fine and installs fine with that. The problem is I can't seem to get Godot to find or import the extension.

Can you advise on how to create a working Godot project with this? Do I need to edit my project file? Or add this extension via the project plugin list somehow?

Also, is it possible to use this repo for multiple (unrelated) C++ extensions in the same Godot project? How does the folder structure change in that case?

Maybe consider extending the readme or adding a wiki article?

Thanks!

@ahrbe1
Copy link
Author

ahrbe1 commented Sep 9, 2024

Ok. After poking around with this more I wound up having to tweak a couple things to get this to build and load for me in Godot 4.3 under MSVC 2022 on Windows 10:

# checkout the C++ bindings to match Godot 4.3
cd extern/godot-cpp
git checkout 4.3
# fix cmake issue with unquoted variables near line 100
vim extern/godot-cpp/CMakeLists.txt
- string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
+ string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# disable warnings-as-errors
vim cmake/CompilerWarnings.cmake
-option( ${PROJECT_NAME_UPPERCASE}_WARNING_AS_ERROR "Treat warnings as errors" ON )
+option( ${PROJECT_NAME_UPPERCASE}_WARNING_AS_ERROR "Treat warnings as errors" OFF )
# Godot won't load the gdextension unless I edit this file
vim MyPlugin.gdextension
- linux.release.x86_64 = "lib/Linux-x86_64/libMyPlugin.so"
- windows.release.x86_64 = "lib/Windows-AMD64/MyPlugin.dll"
+ linux.x86_64 = "lib/Linux-x86_64/libMyPlugin.so"
+ windows.x86_64 = "lib/Windows-AMD64/MyPlugin.dll"

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

1 participant