Closed VadimkaG closed 1 month ago
On windows it requires SDL.lib I downloaded SDL2-devel-2.26.5-VC.zip (from libsdl-org/SDL github) and unpacked .lib files into the project directory (For Image and TTF I also downloaded from github)
I checked for myself, it's named SDL2.lib
, which any linker should be able to find with -lSDL2
(or equivalent) if it's installed in the right place.
When compiling I get the following errors:
lld-link: error: undefined symbol: _D6bindbc6common7codegen6FnBind9__xtoHashFNbNeKxSQBvQBrQBnQBiZm
lld-link: error: undefined symbol: _D6bindbc6common7codegen6FnBind11__xopEqualsMxFKxSQBwQBsQBoQBjZb
DMD64 D Compiler v2.105.0-dirty DUB version 1.34.0, built on Aug 1 2023
Seems that the linker is failing to find the compiler-generated methods in FnBind
that allow it to be a key in a hash map. Perhaps those methods were never generated by the compiler because they are only used in CTFE?
I suspect this is some kind of compiler frontend bug. Please try the latest version of DMD, and also try LDC2 to see what happens.
Looks like this really is a DMD bug. I tried the latest version of DMD, but I encountered the same problem. I tried to install LDC and it compiled without errors
It seems that I jumped to conclusions. It compiles well, but requires a sdl.dll. What did I do wrong? Why isn't it built into a static application?
It compiles well, but requires a sdl.dll. What did I do wrong?
You haven't shown any errors where your linker was unable to find symbols from SDL2, so your issue is probably not related to SDL2 at all. Make sure to use dub --force
when test re-compiling your project without modifying your code.
Why isn't it built into a static application?
Do you mean why wasn't SDL2 isn't statically linked? (i.e. included in the application binary) Well, a .dll
is a shared library, you can't statically link against it; that's what the .lib
is for. Most linkers prioritise shared library files over static ones, so when there are shared and static versions of a library, the shared one will be used.
Please note that SDL is intended to be dynamically linked, because it allows users to update to newer versions of the library (with the latest bug-fixes) without you having to update your software. And there is not really a tangible benefit to static linking over dynamic linking. If you insist on statically linking however, you will have to also link against all of SDL2's dependencies (as static libraries). These dependencies will be different for different platforms, but you can usually just look up each symbol the linker fails to find and figure out what library it belongs to. That said, I do not recommend doing this for SDL2 at all.
Do you mean why wasn't SDL2 isn't statically linked?
yes thanks for the explanations and help.
dub file:
It works great on Linux On windows it requires SDL.lib I downloaded SDL2-devel-2.26.5-VC.zip (from libsdl-org/SDL github) and unpacked .lib files into the project directory (For Image and TTF I also downloaded from github)
When compiling I get the following errors:
lld-link: error: undefined symbol: _D6bindbc6common7codegen6FnBind9__xtoHashFNbNeKxSQBvQBrQBnQBiZm
lld-link: error: undefined symbol: _D6bindbc6common7codegen6FnBind11__xopEqualsMxFKxSQBwQBsQBoQBjZb