I'm new to to C++ and CODE::BLOCKS (about a week in) and I had this same issue. The answers are fine, but implementing them is not explained for a complete noob like myself to follow. (Like telling a caveman to put the key in the ignition. "What's a KEY? What's an IGNITION"?) After enough poking around, I compiled (no pun intended) this solution:
On the CODE::BLOCKS menu (I have v20.03), click "Settings", then "Compiler...".
On the left, click "Global compiler settings" (default).
Under the "Compiler Settings tab", check the boxes next to:
static libgcc [-static-libgcc]
static libstdc++ [-static-libstdc++]
Under the "Linker settings" tab, enter the following in the "Other linker options:" box:
-static -lpthread
Click "OK" and you're golden! Your compiled C++ EXE can run as stand-alone.
I've tried this by compiling a couple of my lesson projects and it's worked. It adds about 2.3MB to the EXE size. No promises that this will work with all of your projects, only that it's worked for me so far.
UPDATE, 2021-01-12 -- Shrink your EXEs!:
While in the "Compiler Settings" tab, scroll down to "Optimization" and check:
Strip all symbols from binary (minimizes size) [-s]
This shrunk one of my compiled EXE files from 2354k to 820k!