Linking DLL's into exe

Currently I have 4 DLL’s in my first SDL2 game - so no doubt more DLL’s will be required. I haven’t added sound yet for example.

Is there anything in the licence that forbids linking DLL’s into the exe?

And if not, has anybody got a simple step by step guide for doing so?

I’m using Visual Studio 2017 Community.

Thanks in advance, Steve.

I’m assuming you’re asking if you can link SDL2 statically with your application.

Yes, the zlib license used by SDL2 (and other SDL libraries) does not place any restrictions on how you distribute the binaries. More information at

It is a bit discouraged, as it makes it harder for the end user to update or modify the SDL2 code used by your application.

Other things to consider:

  • The default configuration will compile SDL2 without needing a C runtime on Windows. This works, but the Microsoft Visual C compiler can generate calls to functions that require the C runtime and you may get linking errors in certain situations. If you already build your application with the C runtime, there’s no harm in adding HAVE_LIBC to the Preprocessor Definition when building SDL2 statically. I think this is even recommended.

  • All other libraries that depend on SDL2 also need to link to it and you have to recompile them too.

You can build a static SDL2 library by downloading the SDL2 source from the website. Open the SDL Visual Studio solution in the VisualC directory and let it be updated to the new target and platform. In the project properties of the SDL2 project, change the Configuration Type to Static Library. I also recommend adding _static at the end of the Target Name to prevent conflicts with the import library from the SDL2 DLL. Build the project and you should have a SDL2_static.lib in the output directory which you can use with your application.

Note that SDL2 requires a few Windows DLLs and because linking now happens when you build your application, you have to add those import libraries to your project. The Visual Studio project currently uses these: winmm.lib;imm32.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib.

(I used the SDL 2.0.6 source to test this.)

Thanks for your detailed answer ChliHug!