Getting C++ to compile as a shared object/dll

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

Hello,

I am trying to compile a module I have made in C++ and it works flawlessly when I do it as a static build.

When trying to compile it as a dynamic library, it fails entirely though; even with the simple example provided in the Godot documentation : Godot Custom C++ Modules.

It basically cannot resolve externals references when linking the library.

e.g.

sumator.windows.tools.32.obj : error LNK2019: unresolved external symbol "public: static void __cdecl ObjectTypeDB::get_property_list(class StringName,class List<struct PropertyInfo,class DefaultAllocator> *,bool,class Object const *)" (?get_property_list@ObjectTypeDB@@SAXVStringName@@PAV?$List@UPropertyInfo@@VDefaultAllocator@@@@_NPBVObject@@@Z) referenced in function "protected: virtual void __thiscall Reference::_get_property_listv(class List<struct PropertyInfo,class DefaultAllocator> *,bool)const " (?_get_property_listv@Reference@@MBEXPAV?$List@UPropertyInfo@@VDefaultAllocator@@@@_N@Z)

In total, it misses 46 unresolved externals. I tried with both MSVC15 and GCC 5.3 on Windows. (Haven’t tried on Linux nor OSX)

Anybody does have a pointer how to quickly fix this ? Or does the tutorial only works in Linux ? (as it mentions *.so). If too nasty to fix, I suppose i’ll have to wait until Godot3 is out. (Must admit I can’t be more excited ! :p)

:bust_in_silhouette: Reply From: vnen

I don’t think you can dynamically link a module. The only thing you can do is create a statically linked module that dlopen() a library. That’s the problem that GDNative will solve in Godot 3.0.

Well thank you for confirming. It was already looking a bit too magical in the documentation.

It should be amended in order to avoid inducing users in confusion. How can I propose my help for documentation ? (I’d like to help the Godot project in general :slight_smile: )

MaximeG | 2017-08-07 14:14

I never realized the documentation shows a way to dynamically link the module. If you follow all the steps and it didn’t work, might be a problem with the documentation itself (it seems to be focused on Linux only, indeed).

If so you can open an issue on https://github.com/godotengine/godot-docs

vnen | 2017-08-07 15:53