How do I create a C++ script in Godot 3.0, I keep getting an error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Joe0239
:warning: Old Version Published before Godot 3 was released.

enter image description here

I want to create a C++ Script And this is how I created it

Now when I created it, then I get this error

How do I solve this?

:bust_in_silhouette: Reply From: snwflk

You can’t code directly in C++. However, there are 2 ways of using C++ in Godot:

  1. Custom modules.

  2. GDNative.
    As writing custom modules is meant for adding functionality to the engine hence it’s advanced, the most fit way to code game play would be GDNative in the form of a library.
    So, here’s the workflow with GDNative:

  3. You write your cpp/h files in an external IDE (like MSVS). The cpp has additionally code for registering classes and methods to be used in Godot.

  4. Build them into dll’s (Windows) / so’s (Linux). To do this you have to download
    cpp bindings and Godot headers.

  5. In Godot you create a GDNativeLibrary (on disk it has gdnlib extension).

  6. In Godot you create a NativeScript (on disk it has gdns extension). This has to be based on the gdnlib above.

  7. In the node you want the C++ functionality, you create a regular GDScript and you call the registered methods from within there, like you’d call methods from any dll native library.

GDNative is still work in progress and there are no straightforward tutorials on it but Readme.md from cpp bindings is a good start.

Would it be this complicated int he future, as you said GDNative is still work in progress?

Joe0239 | 2017-12-18 09:51

If I’m not mistaken I’ve seen changes on the GDNative C++ part like complicated method calling i.e. gdn.call_native("standard_varcall", "some_test_procedure", []) for calling some_test_procedure(), getting slimmed down to just calling f.i.cppClass.some_test_procedure().
I’m expecting improvements even further but I don’t know how further.
For more info on C++ coding in Godot check these out:
https://forum.godotengine.org/16746/will-c-ever-be-built-into-godot?show=16746#q16746

Loading...

https://godotdevelopers.org/forum/discussion/comment/20466/#Comment_20466

snwflk | 2017-12-18 11:13

Thank you for your help.

Joe0239 | 2017-12-18 11:50

You’re welcome. After a while, if you won’t receive any more answers, please consider voting/accepting the answer. You can revert at any time :slight_smile:

snwflk | 2017-12-18 11:55

I voted the answer :slight_smile:

Joe0239 | 2017-12-18 11:57

:bust_in_silhouette: Reply From: ProggerParrot

You have a lot of possibilitys to use native Code in Godot Engine!
I’ve made some videos about this topic, and collected the most important once here in my Steam guide :slight_smile:

enter image description here