+5 votes

Hello everyone!

I need to use an extensive C++ library in my project and I would like if there is a way to use this library directly in GDScript or how can I approach this easily.

I already checked the modules page in the documentation but I would like to find an easier work around since doing that would be overkill, literally.

I tried to find how to use C++ for the entire application if the previous approach was not possible, but I didn't find a way to accomplish this without GDScript.

Thanks!

asked Aug 15, 2016 in Engine by Not_a_Robot (82 points)
edited Aug 15, 2016 by Not_a_Robot

1 Answer

+1 vote
Best answer

If you want to use a C++ library you need to make a C++ module to make a bridge with the engine (create new nodes, expose API to GDScript, etc.). I can't see how that's overkill.

Making a module is quite easy. You'll likely have more trouble compiling the library with SCons for multiple platforms.

answered Aug 15, 2016 by vnen (773 points)
selected Aug 15, 2016 by Not_a_Robot

Well, the library is huge, it will be a lot of hardwork.

Thank you four your answer :)

If it's huge, you should ask yourself if you really need it. Also, the bridge doesn't need to have all of the interface if you're not using everything. Maybe a couple of nodes might be all that is needed to encompass a lot of the lib's functionality.

(I wonder why my answer got downvoted. It'd be nice to leave a comment saying why this answer is not good, so I can improve it).

Is there an (prototypical) example in the sources or some good place to look into for this?

Besides the documentation on making modules you can check some other modules as references such as the ones listed here or here.

vnen, I don't know why but I expected a «ask yourself if you really need it.» comment haha :)

Yeah, I really need that library. I wish I could use C++ without GDScript because that would make my life easier I think.

I'll try to make that library as a module then, although you scared me talking about SCons (never heard of this before), because the game is going to be published for Android phones.

I'll take a look at those examples you share, thank you very much!

(btw, I have no idea about the downvote, I selected your answer as the best, so...)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.