Hi, I’m trying to link a pre-compiled third party DLL to my C++ module and seem to be having a bit of an issue. My SCsub file currently looks like this:
But the problem with this is as soon as I use any of the functions from the third party library I get an unresolved external. Which implies it’s not actually linking to the library in the first place.
Other solutions I have tried are:
changing env_slang to env when appending the library path and the libs list. But that changes the error from unresolved external to missing a file that Godot thinks should have been built.
Manually linking via command line passed to the CCFLAGS variable, but in all cases that has resulted in the compiler thinking that the third party library is a source file of some kind, not a library.
So I did try that, doesn’t work either. It complains that the linker can’t find the file slang.windows.editor.double.x86_64.lib. Almost as if it was expecting to have built that file itself instead of just linking to the file I provided.
I even tried renaming my slang.lib and slang.dll files to match the one godot was expecting with no difference in error message.
Figured it out, the reason that env_module was undefined is because it was env_modules. Spotted that in the other post. But I didn’t need that if I changed env.Append(LIBS=["slang"]) to env.Append(LIBS=[File("external/lib/slang.lib")]).
Or at least it builds, need to actually test it runs with the DLL alongside it. I will run it and get back to you
Tested it, it runs. Resources and Nodes show up as expected and if I remove the DLL from alongside the engine it fails to launch. All signs indicate it’s working now.
Really not sure why I have to specify the file being linked to such specificity, but working is better than not working. So I am not gonna complain too much
I do agree that the solution I found in the other post doesn’t seem completely correct. There were some odd things from the Godot’s build system that seemed a little weird like it wanted to look for libraries in platforms, instead of modules.
maybe the official example is incorrect, or outdated.
I had considered opening an issue on the GitHub. But I don’t know nearly enough about Godot’s build system to conclusively say it’s a bug and needs fixing.