• Godot HelpQuestion
  • compiling a GDNative C++ dll in Visual Studio I get 4 things aren't in my class

So I am just starting to use GDNative with C++. I would also like to know how I can use a string in my code. I have compiled the godot-cpp from Github. here is my code:

//main.cpp

#include "Interpreter.h"

extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options * o) {
    godot::Godot::gdnative_init(o);
}

extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options * o) {
    godot::Godot::gdnative_terminate(o);
}

extern "C" void GDN_EXPORT godot_nativescript_init(void* handle) {
    godot::Godot::nativescript_init(handle);

    godot::register_class<godot::Interpreter>();
}

//Interpreter.h

#ifndef INTERPRETER_H
#define INTERPRETER_H

#include <Godot.hpp>
#include <Node.hpp>
//#include <string>
//#include <string.h>
#include <Python.h>
#include <vector>
#include <numpy/arrayobject.h>
//#include <Variant.hpp>
namespace godot {
	class Interpreter : public Node
	{
	public:
		static void _register_methods();
		Interpreter();
		~Interpreter();
		//std::string code;
		void runcode();

		void _init();
		void _process();
	private:
		bool isRunning = false;
	};

}

#endif

//Interpreter.cpp

#include "Interpreter.h"

using namespace godot;

PyObject* myfuzz(PyObject* self, PyObject* args) {
    if (!PyArg_ParseTuple(args, ":fuzz"))
        return NULL;
    

    return Py_None;
}

PyObject* PyInit_emb() {
    static PyMethodDef EmbMethods[] = {
        {"fuzz", myfuzz, METH_VARARGS, "Make fuzz sound"},
        {NULL, NULL, 0, NULL}};

    

    static PyModuleDef EmbModule = {
        PyModuleDef_HEAD_INIT, "AEInternal", NULL, -1, EmbMethods,
        NULL, NULL, NULL, NULL
    };
    return PyModule_Create(&EmbModule);
}

void Interpreter::_register_methods() {
    register_method("_process", &Interpreter::_process);
    register_method("_init", &Interpreter::_init);
    //register_property<Interpreter, std::string>("code", &Interpreter::code, "");
}

Interpreter::Interpreter() {

}
Interpreter::~Interpreter() {

}

void Interpreter::runcode() {
    if (!isRunning) {
        isRunning = true;
        //PyRun_SimpleString(code.c_str());
    }
}

void calledStart() {
    PyImport_AppendInittab("AEInternal", &PyInit_emb);

    Py_Initialize();
    if (_import_array()) {

    }
}

void Interpreter::_init() {
    calledStart();
}
void Interpreter::_process() {


}

    You can use a C++ standard String, but you'll need to convert it to a Godot specific class if you want to pass it back and forth.

    In Godot 4.0, GDNative will be replaced by GDExtensions.

    AI_Messiah how I can use a string in my code

    Well, not sure what the question is, could you clarify ? One uses a string, be it std::string or godot::String or any classes with character-manipulation included into the code, to store and manipulate sequences of characters.

    It is up to you to choose between them, or even roll your own if you deem it necessary.

    Btw, what's that Python stuff for ? Wouldn't you want to separate Python scripts from C++ code ?