As mentionned several times in this forum, you can also have problems with other dlls as libgcc_*.dll or libwinpthread-1.dll.
You can add these in your .exe directory, OK.
But if you want to execute directly other compiled programs, you'll have the same problem. So, I think a good solution is to add the path of these dll, which is something like C:\MinGW\bin (but may be different for you), in your PATH variable. When you run your executable from inside codeblocks, codeblocks do the job for you, but only for itself.