Ask HN: Why isn't it easy to compile dlls inline?
I was dinking with some c++ and I wonder why it's not simple to just inline dlls when you do a release build? Seems like it would be easier. Is this a relic from when disk space was at a premium and it just never changed?
I'm trying to compile some code and it works, but I found I have to copy the dll to the working dir and I was just wondering why cmake or vs build doesn't just have a "fat binary" build... would make life easy. Not complaining, just wondering.
9 comments
[ 1.8 ms ] story [ 39.7 ms ] threadNote that the objdump command[1] from GNU binutils works on Windows .lib, .dll, and .exe files, if you want to know more about what they contain.
[1] https://sourceware.org/binutils/docs-2.42/binutils/objdump.h...
https://learn.microsoft.com/en-us/dotnet/core/deploying/sing...
There are valid reasons for dlls however. The main one being symbol name collision.
For example, you can use a dll that links to version 1 of a library, while using version 2 of the library yourself without having any name collisions.
Many years ago when I did Linux development this was a main gripe of using .so files - imported names could clash with the same global names in your program and you get random runtime behaviour.
Just.. Wow. The ignorance of people is shocking. Some guy even said that it's not possible because a DLL can contain an entry point which is called when the DLL is loaded and a static library has no such thing... well nothing prevents me from manually calling such entry point from my main function. At the end it's all executable code, and it's absolutely possible to relocate some addresses and repackage the code as a static library. It's just that no one with the knowledge had a need to do it.