I am using SDL2 and SDL2 image with c++ and there are So many DLL's which are neccessary for the main.exe to run. I want to submit the project in single main.exe file without the dll's. Is this possible?
Asked
Active
Viewed 223 times
0
-
That sounds like you want to statically link the library instead of using dynamic linking: https://wiki.libsdl.org/Installation#static_linking – UnholySheep Aug 12 '22 at 12:07
-
1See also [this question](/questions/17620884/static-linking-of-sdl2-libraries) and many others like it. – Botje Aug 12 '22 at 12:08
-
Of course you can write a program which converts the DLL's to e.g. byte arrays and then embed this in your Exe, which needs to write em back to the file System at the first start... I did this with Icons n stuff, so much smaller. But the principle is portable – schnedan Aug 12 '22 at 12:14
-
@schnedan: Not really. When Windows loads your executable, it will already resolve the DLL's. This happens before your `main` runs, so you can't extract the DLL's in time. Icons are needed later, so they do work. – MSalters Aug 12 '22 at 12:34
-
@MSalters that can be avoided by dynamic/delay-loading the DLLs. – Remy Lebeau Aug 12 '22 at 19:12
1 Answers
3
Not if you are linking against the dlls. This can only be done it they are all static libraries, not dynamic libraries (dlls).
(If using the dlls) Possibly best to try to page them together in a single folder. A self extracting executable, that automatically runs could an an option depending on your goals.
Edit: Apparently you may be able to do it if you build SDL 2.0 yourself as a static lib - this suggests it's possible (for windows) https://wiki.libsdl.org/Installation#static_linking

Malcolm
- 56
- 4
-
1"No" is somewhat misleading. SDL2 does ship static libraries, so it's possible. – HolyBlackCat Aug 15 '22 at 08:34
-