Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you build replaceable DLLs with visual studio?

I'd like to build certain extensions of my game into a DLL so that I can recompile the extensions and replace the DLL without rebuilding the entire game. How do I go about doing that?

I read somewhere that each new version of the DLL would have to be "binary compatible" with the old one. Are DLLs compiled with visual studio binary compatible by default as long as I don't change the function names?

like image 787
CuriousGeorge Avatar asked Jan 23 '26 10:01

CuriousGeorge


1 Answers

You have to do more than just keep the function names the same. What you have to ensure is called Application Binary Interface, or ABI, compatibility.

There's lots of stuff this entails beyond just symbol names. For example, you have do things like to keep data structures that are passed across the DLL boundary the same size, and the compiler has to place any class members defined in your module but accessed outside of it in the same relative location. A lot of it is up to the compiler's ABI. Microsoft compilers have a bad habit of not being ABI compatible across versions, while some other compilers work a little harder at being compatible. But remember that it requires more than just using the same compiler.

You'll probably need to read up on maintaining ABI compatibility in your environment because it probably involves more details than could be listed here and there are lots of ways to go wrong. Here's one short article on it. There may be better ones specifically for MSVC compilers.

like image 110
bames53 Avatar answered Jan 26 '26 01:01

bames53



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!