Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open dynamic library: [...] error: Error 126: The specified module could not be found. But the .dll is right there #1064

Closed
fenix-hub opened this issue Mar 4, 2023 · 5 comments · Fixed by #1203

Comments

@fenix-hub
Copy link

System: Windows 11
Godot Version: v4.0.stable.official.92bee43ad
godot-cpp version: 4.0 branch
extension source code: qrnative

Last time I tried to compile and use my custom extension worked (it was on Godot 4 beta 3).
Even after updating everything, and following the documentation, when I try to use the .dll in Godot after compilation of both godot-cpp and my library, the following message appears in the Editor:

Godot Engine v4.0.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
  modules/gltf/register_types.cpp:70 - Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported.
--- Debug adapter server started ---
--- GDScript language server started ---
  Can't open dynamic library: D:/Development/GodotEngine/4.x/qrnative-cpp/project/addons/qrnative/bin/windows/libqrnative.windows.template_debug.x86_64.dll, error: Error 126: The specified module could not be found.
  .
  core/extension/gdextension.cpp:400 - GDExtension dynamic library not found: D:/Development/GodotEngine/4.x/qrnative-cpp/project/addons/qrnative/bin/windows/libqrnative.windows.template_debug.x86_64.dll
  Failed loading resource: res://addons/qrnative/qrnative.gdextension. Make sure resources have been imported by opening the project in the editor at least once.

Altough the path to the .dll is correct and there are no typos.
image
Here's the .gdextension file

[configuration]

entry_symbol = "qrnative_init"

[libraries]

windows.debug.x86_64 = "bin/windows/libqrnative.windows.template_debug.x86_64.dll"
# also tried with "res://addons/qrnative/bin..."

I've put the link to the source code, if anybody using w11 want's to try to test the extension. The source code contains the example project used in this issue.

Anyway, compilation tests work on all of the desktop platforms, so I don't know if I'm really missing something or it is something on Windows 11.

@fenix-hub
Copy link
Author

Found related issue already opened, though #976 mentions that beta 8 and 9 have been tested. So this could be a regression introduced in previous beta releases.

@SeleDreams
Copy link
Contributor

I noticed it tends to happen with dlls built with mingw, i noticed building with MSVC instead tends to fix this issue

@bruvzg
Copy link
Member

bruvzg commented Mar 8, 2023

Check for the library dependencies (and dependencies of dependencies, use tools like https://github.com/lucasg/Dependencies to check it). All non-system libs should be in the same folder as the GDExtension library. Windows return the same The specified module could not be found error, regardless of which file it was not able to load.

@ghsoares
Copy link

I was getting the exact same error, I was being able to compile the library but the editor couldn't load the .gdextension resource, throwing error 126 as the library was being linked dynamically instead of linking statically. The PR #1082 fixed my issue by passing the static flags to the linker.

@TokisanGames
Copy link

I had been building my plugin hundreds of times successfully with MSVC on 4.0.2. I added this to my class:

	static inline const String TYPESTR[TYPE_ALL] = {
		"TYPE_HEIGHT",
		"TYPE_CONTROL",
		"TYPE_COLOR"
	};

It compiles fine, but suddenly Godot can't find the extension:

ERROR: Can't open dynamic library: C:/GD/_plugins/TerrainGDEX/project/addons/terrain/bin/libterrain.windows.debug.x86_64.dll, error: Error 1114: A dynamic link library (DLL) initi.
.
   at: (platform/windows/os_windows.cpp:302)
ERROR: GDExtension dynamic library not found: C:/GD/_plugins/TerrainGDEX/project/addons/terrain/bin/libterrain.windows.debug.x86_64.dll
   at: open_library (core/extension/gdextension.cpp:400)
ERROR: Failed loading resource: res://addons/terrain/terrain.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
   at: (core/io/resource_loader.cpp:222)
ERROR: Error loading extension: res://addons/terrain/terrain.gdextension
   at: (core/extension/gdextension_manager.cpp:120)

I changed it to static inline const char* TYPESTR[TYPE_ALL] and it compiles and runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants