migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
987 stars 55 forks source link

Failing to use compiled DLLs on Windows #453

Closed elijah-semyonov closed 2 months ago

elijah-semyonov commented 2 months ago

Hey!

Thanks for awesome work. Everything works spectacular on macOS so far, but when it comes to Windows, everything builds well not counting the warning like:

Z:\.build\x86_64-unknown-windows-msvc\debug\SwiftSyntaxMacros.build\MacroExpansionContext.swift.o: locally defined symbol imported: $s16SwiftDiagnostics10DiagnosticVMn (defined in Z:\.build\x86_64-unknown-windows-msvc\debug\SwiftDiagnostics.build\Diagnostic.swift.o) [LNK4217]

When I actually try to bind the resulting dll in the same way I do on macOS I end up with really awkward error:

Can't open dynamic library: 
C:/Projects/swift_godot_project/bin/~example_library.dll. 

Error: Error 126: The specified module could not be found.
core/extension/gdextension.cpp:719 - GDExtension dynamic library not found: 
C:/Projects/swift_godot_project/bin/~example_library.dll. 

Failed loading resource: res://bin/[library-name].gdextension. 
Make sure resources have been imported by opening the project in the editor at least once.
editor/editor_node.cpp:1225 - Condition "!res.is_valid()" is true. 
Returning: ERR_CANT_OPEN

It seems like it has something to do with this piece of code judging by ~ in front of the dll filename in Godot itself. But I really struggle to figure out what the actual problem is.

I've used Procmon to see if there is actually a problem with some of DLLs not being resolved correctly, but this wasn't the case.

Both example_library.dll and SwiftGodot.dll are in the bin folder.

The sources is just an example code with SpinningCube. I'm using the official 4.2.1 release of Godot.

niktek commented 2 months ago

Following from here: https://migueldeicaza.github.io/SwiftGodotDocs/documentation/swiftgodot/workinginvscode/#Windows

Key things are: ensuring the lib/dep targets are windows.debug_x86_64, that you copy the Swift runtime files - which may not be in the stated location if you use WinGet or Scoop to install Swift - use where swift on the command line to get it's location and copy the runtime dll's into your Godot projects /bin . You do not need to rename your files with the ~ in front of them either.

Can confirm that the Simple Runner tutorial works on Windows

elijah-semyonov commented 2 months ago

I've made a mistake and copied wrong Swift DLLs (not from Runtime folder). Procmon showed, that they were resolved correctly, but in the end Godot couldn't link it. Now everything works, thanks.