Seems like nobody talked about this method. So I’m posting it here.
First of all, install X11 apps using apt-get. You need to first remount your root as read-write:
http://askubuntu.com/questions/399709/install-with-sudo-app-get-install-doesnt-work-not-using-locking-for-read-only
Then, you can first start a builtin X11 app, for example the gedit app from scope. And then run this in terminal:
DISPLAY=:1 codeblocks
If you want to run Qt apps, see this first(export MIR_SOCKET):
http://askubuntu.com/questions/611274/how-do-i-run-a-mir-application-from-a-command-line