2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
942 stars 82 forks source link

Windows library doesn't work if VCRUNTIME.DLL is missing on host device #33

Closed 2shady4u closed 2 years ago

2shady4u commented 3 years ago

Basically if the host device doesn't have any VC++ redistributables installed, the DLL library will fail to load on Windows devices. This is due to the fact that the DLL has a dependency on VCRUNTIME.DLL libraries that has to be satisfied.

Two possible options are available to solve this issue:

1. Change the MSVC compilation flag from /MD to /MT

This would results in a DLL that includes the runtime dependencies and thus does not dependent on any VC++ redistributables being installed on the host. https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-160

This would require the godot-cpp-repository to update their SConstruct to give the option to select this compilation flag since both the bindings and the library have to be compiled using the same flag. Or I could simply rewrite the SConstruct to handle compilation of both bindings and godot-sqlite in the same file.

2. Compile the library with MinGW instead of MSVC.

Compilation using the MinGW compiler is possible, but currently results in huge library sizes (~14 MB). Most likely due to the fact that the SConstruct doesn't properly set the correct compilation flags for the release target. This might be fixable by only modifying the SConstruct of this library, but I don't know enough about MinGW to make a correct judgement on this one.

Both options are feasible, but I'll have to do some more experimentation and research to resolve this issue in the best way possible...

progsource commented 3 years ago

In the meantime it would be nice to have a hint in the readme, so that users of the plugin do not run into "No valid library handle" while trying it out ;)

Aspire5 commented 3 years ago

In the meantime it would be nice to have a hint in the readme, so that users of the plugin do not run into "No valid library handle" while trying it out ;)

Yes, Please. I could have never figured it out by myself without the help of @progsource

2shady4u commented 3 years ago

A section has been added to the README.md that addresses this issue.

2shady4u commented 3 years ago

a third option would be to cross-compile for windows using a linux host device. This might be the solution in this case.

2shady4u commented 3 years ago

I've added a cross-compilation build for Windows to Github Actions which can be downloaded here.

Why is this build not included in Godot SQLite by default?

Currently the binary is excessively large... (~7 MB) There's probably an additional compilation/linker flag that I'm missing to reduce the file size to something more respectable (probably around 4-5 MB). Once I figure out the offending flag, this cross-compilation build becomes the default and closes this issue as a result.

2shady4u commented 2 years ago

I'm closing this issue as the default Windows binary included with this plugin is now the MinGW cross-compiled version by default.