#pragma comment(lib, "<library_name>.lib") for Windows native extensions

Hi,

Will #pragma comment(lib, “<library_name>.lib”) work for Windows native extensions to link with Windows built-in libraries?

Thanks,
Martin

1 Like

This depends on how Defold loads libraries, but since it’s designed to be cross platform, provided the needed support for loading libraries exists for Windows and the translation to .dll is done for you behind the scenes, there’s no reason this wouldn’t work. It would be nice if it did, since then you could use multiple platform-specific versions of the same native library and load the right one with the same command. This obviously requires the library filename to be identical (excluding the extension) everywhere it’s loaded.

1 Like

At the moment it looks like it is not working as I get unresolved external symbols which should be included in the library which I try to link to using #pragma comment(lib, “.lib”) but I don’t get the errors if I manually add the library in lib folder in the extension folder.

Are you including a static lib?

yes i am

Then I think you don’t need any pragma commands. Just drop it into the lib dir under win platform.

3 Likes