Code Monkey home page Code Monkey logo

godot-native-example's Introduction

Godot Native Example

In this project:

  • An example C++ GDNative plugin.
  • Instructions to build the plugin including what software you'll need.
  • Support for 💰Windows, 🐧Linux & 🍏MacOS (x86_x64/arm64).
  • 🤖 An automated build pipeline to build for all above platforms.

Buildling on Windows 💰

  1. Download and install:

  2. Open a CMD window and run the following commands:

git clone https://github.com/samsface/godot-native-example.git
cd godot-native-example
debug.bat
  1. Open godot-native-example.sln that should of been generated by running debug.bat in previous step.

  2. Run the godot project in the app directory of this repo. If it prints "ciao" to the output, it worked!

Building on Linux 🐧

  1. Install tooling:
sudo apt-get update && apt-get install build-essential cmake python3-pip
  1. Clone the project and build
git clone https://github.com/samsface/godot-native-example.git
cd godot-native-example
sh debug.sh
  1. Run the godot project in the app directory of this repo. If it prints "ciao" to the output, it worked!

FAQ

  • You DO NOT need to copy the build files into the Godot project. CMake does this for you.
  • You DO NOT need to restart Godot every time you rebuild. Godot will reload the plugin.
  • On Windows, you need to stop debugging in Godot to rebuild, else you'll get a permission denied error installing the dll.

Using the CI:

This project contains a github actions file that will build your project for all supported platforms every time you push changes. To use it, just Fork this project and then just push changes. You'll see the build status in the Actions tab of your fork.

  • Github actions free tier only gives you so many minutes of compute per month so be conciuous of this.

godot-native-example's People

Contributors

lyfflyff avatar samsface avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot-native-example's Issues

How do you properly export the example project?

Hello. I'm back again, this time with a non-duplicate issue. I now know how to check the closed issues before submitting my own (lol).

I'm not aware of any kind of special procedure for exporting with GDNative, so I simply used the traditional 'Project > Export' method in the Godot editor. The project works as intended on my computer, but when I send it to my friend's they get this error instead:

ERROR: Can't open dynamic library: addons/example/gdnative-example.dll, error: Error 126: The specified module could not be found.
.
   at: (platform/windows/os_windows.cpp:2353)
ERROR: No valid library handle, can't get symbol from GDNative object
   at: get_symbol (modules/gdnative/gdnative.cpp:510)
ERROR: No nativescript_init in "res://addons/example/gdnative-example.dll" found
   at: init_library (modules/gdnative/nativescript/nativescript.cpp:1510)
ERROR: Error opening file 'res://icon.png'.
   at: load_image (core/io/image_loader.cpp:55)
SCRIPT ERROR: Attempt to call function 'new' in base 'NativeScript' on a null instance.
          at: _ready (res://example.gdc:5)

Despite what the error says, the .dll is clearly in that directory. I found a similar issue and what I think is happening is the .dll isn't able to load because of dependencies available on my machine, but not on others'. Here's a list of the file's dependencies:

MSVCP140D.dll
VCRUNTIME140D.dll
VCRUNTIME140_1D.dll
ucrtbased.dll
KERNEL32.dll

I saw two other similar issues, but I'm not familiar enough with VS or CMake to know out how to configure these so-called 'flags'. I assume I have to modify either 'CMakeLists.txt' or 'CMakeCache.txt', but I'm not exactly clear on what changes I'm supposed to make.

One of the issues suggested building in release mode, but when I tried that I received a few hundred errors like this one:

godot-cpp.windows.debug.64.lib(String.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Godot.obj

I've been trying to figure this out myself for a few days, but I just feel lost so now I'm asking for help again. I'm sure I'm just missing something very simple like last time.

how to set up for Linux/Ubuntu?

Hope you're is going well.
But I would like some help finding all the prerequisites, and setting this up in Ubuntu, I already know a few of them such as Mono, git, and Python3 along with their dependencies and an IDE which I have been on the hunt for. However since this isn't Windows there are going to be at least a few differences with setup, so I would like help finding what those differences are, and what to do to get around those.

what is the best route for FFMPEG as a Godot plugin

Hello, hope you're is going well, but I'd like some help

Details

How would I go about implementing the FFMPEG libraries (FFMPEG is a leading multimedia codec) as a Godot plugin and not as a module (as I feel it would be more cumbersome to maintain as a module). I know a decent amount of how to use FFMPEG in C++ if that's useful. Help and suggestions on how to do this would be greatly appreciated.
If you need any more information I would be glad to provide it.

'MSB3073 The command "setlocal' error occurs seemingly randomly when installing

I know my code is fine because I don't receive any errors when building the project and I have been able to occasionally get the install to work and test my C++ code in Godot, but more often than not I get this error whenever I try to install.

I've tried a couple of solutions from googling the error, which included unsetting all of the project files from read-only and running VS in admin mode, but neither of those made any difference. The only solution out of the three I've tried that seemed to have some effect was restarting my computer. After rebooting my system without making any changes to my code I stopped receiving the error for around two hours until it suddenly started happening again.

Here's an image of the error and the code it takes me to when I double-click it:
error

build process trying to create folder in program files during compilation

Hello, I have an issue on windows 10, when I run debug.bar I get this error:

image

I looked into the scripts and it seems that it come from this part:

# Set the install prefix if(NOT DEFINED CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/gdnative-example") endif() string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")

in cmake_install.cmake

it's generated I guess so I tried to go deeper and I found this part:

# install build into example project by default if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set( CMAKE_INSTALL_PREFIX "../app/addons/example" CACHE PATH "..." FORCE) endif()

In CMakeLists.txt. here i'm stuck, I don't know if I installed something the wrong way or what. Can you help me? I can bypass the error by modifying cmake_install.cmake manually and launching again the command
cmake --build . --target install

but it's not very convenient. btw thanks for this example projet !

ERROR: "The command setlocal"

After folllowing the GDNative Tutorial using Visual Studio 2022 on Windows 10 , everything worked well. But adding or just changing parts of code an Error appears saying "The command setlocal". It appears when building the INSTALL, after building ALLBUILD with no errors of course.

This Error can be temporarly fixed for me by restarting my entire PC, only restarting Visual Studio doesn't work.

Full Error:
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "setlocal
"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd" exited with code 1. INSTALL C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 157

EDIT: Also, it doesn't appear frequently sometimes I comes every 5 minutes and sometimes it doesn't appear at all.

New conan version seems to break the github actions: ERROR: The default build profile doesn't exist.

System:
Windows 10

Issue Description:
Newer actions started using the example project and my own all fail the github action during the building process.

The Error stems from it not finding some default profile:

ERROR: The default build profile '/home/runner/.conan2/profiles/default' doesn't exist.

Old (Working) Build:

image

New Failing Build:

image

My Observations:
I have noticed that the older builds were using Conan 1.58 and Python 3.11.1, but the never ones are using Conan 2.0.0 and Python 3.11.2.

Also the Code/Project builds the debug version fine on my machine, though there is an older installation of conan installed 1.55.0

Possible Fix:
I'm not very experienced with this, but I think there would be two ways of fixing this:

  1. Forcing the Github Action to install an older version of conan instead of the newest one
  2. Somehow making this "default profile"

I'll try to find some fix that will work, but as mentioned I don't have any clue how Github Actions actually function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.