and I am less then an average programmer
I totally agree on that! And because of that it seems you are missing some basic information about what is going on here.
CodeBlocks is not a compiler, its basically a frontend for a compiler. The compiler you are using is gcc and the error you are seeing is from gcc, not CodeBlocks.
Why does code completion of CodeBlocks know about all these X11 headers? Because you told CodeBlocks where to look for them and, big surprise, you told CodeBlocks the correct location?
But why isnt gcc happy with your headers? Well, the compiling stage is, but the linking stage isnt. Because the linker gives a fuck about your headers, all it cares about is libraries.
So you only told CodeBlocks where the headers are which CodeBlocks told gcc, but you didnt tell CodeBlocks where the libraries are so gcc complains about.
So no bad programming here, only bad user here, this cannot be fixed from this side. And before you cry more, it is and has always been the responsibility of the user to setup his compiler environment.