Compilers are normally free; it's the IDE you're paying for. Though, there's different compiler vendors; GCC (MinGW) is free, and so is Microsoft's Visual C++ compiler.
codeblocks isn't a compiler. It's an IDE. You have to tell it which compiler to use, and you have to provide that compiler. One of the download options comes with a compiler as well, to save you separately getting the compiler.