An other solution, more general, is to add the path where this dll is located to your system path (or user path). For me, it's C:\MinGW64\bin but for you it may be something else, depending where you have installed your compiler. Codeblocks add this path in it's own path, but only for executables executed inside codeblocks : it's why your executable works inside C::B but not as a standalone executable. Adding this path to your system path solves this problem but also if your executable(s) needs some other dll in the same path (for example libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll, ...)
Nevertheless, consider that static linking is a good solution, especially if you distribute your code or want it to be executed on an other machine.