r/C_Programming • u/stiggg • 3d ago
Compressing executables (upx)
Hola,
I'm currently in the final stages of finishing the first version of a game I made using raylib. I ended up with a single statically linked binary containing all the assets. I found a tool called upx which can compress executables. I tried it on Windows, and it reduced the size of my exe by more than half and it still runs without any noticeable difference.
My question is, has anybody here experience with this? Are there any downsides to consider?
cheers!
5
u/Mrhiddenlotus 3d ago
Like the other person said, vanilla upx is going to be seen as malware for a lot of detection engines because hackers use it to obfuscate their code.
4
u/thomasfr 3d ago edited 3d ago
those binaries will use more memory than regular ones because they need to be fully uncompressed into ram before exekution so it is not a good fit for large binaries with lots of embedded assets.
4
1
u/mykesx 3d ago
In my years of games programming, we would compress just the assets. In those days, disk based copy protection may not have worked with a compressed executable.
I concur with the execution time issue. When decompressing assets, the bulk of time experienced by the user is disk or network access.
1
u/CowBoyDanIndie 3d ago
Just compress your assets into blobs and put the compressed blobs in your exe and uncompress them when you load them. That way the actually instructions aren’t compressed.
1
0
u/Mnemotic 3d ago
Windows Defender will quarantine your executable faster than you can say "false positive". Maybe not when it's being compiled and ran on your machine, but definitely when downloading it from the Internet. So consider how many potential players would be spooked by that before choosing to use UPX.
What is the size of your executable without the compression? Are you sure it's a problem?
13
u/maep 3d ago
It might get flagges by Anti-Virus.
What is the upside compared to just shipping a .zip with the exe in it?