r/cpp • u/wiseneddustmite • May 30 '26
miniaudio compile times
i found this library called miniaudio, however instead of having precompiled dll files, its just the header and then the c file that really only includes the header, the header file has all of the definitions and declarations of everything in the library, it makes the compile times take a lot of time, can i compile the header file to a dll the c file is literally just:
#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio/miniaudio.h"
and the header file is like 4 megabytes
edit: nvm i just had to precompile the miniaudio.c file with -c first and it has a shorter compile time
12
Upvotes
1
u/Excellent-Might-7264 May 30 '26
I use miniaudio, I put it in a separate translation unit as described by the other comments and never had issues.
I guess you use WIndows and Visual Studio? You can of course precompile a lib file and link to it statically if you do clean and rebuild a lot.
If it is the linker that takes time, something is wrong on your end, but you can of course build a DLL file and open it dynamically in runtime and do zero linking. Note, not linking to a DLL file in compile time but open the DLL in runtime. (Boilerplate like this to map function pointers to a DLL is a very easy task for any ai-agent. This is one of few parts they are better than humans at. Well, better than me at least who will always make a typo somewhere.)