I'm thinking of creating a Game Engine with a C++ Compiler using OpenGL but I don't know how to create a compiler in an application. Do I have to write the compiler? or could I use (for example) the Visual C++ Compiler?
The only reason that I can see for including a compiler in an application is that you wish users to be able to write their own code in C++ which is compiled, linked, and executed at runtime. This isn't a brilliant idea, and in fact there is a common game engine technique called scripting that allows users to do write their own code and have it executed.
A short extract from Jason Gregory's Game Engine Architecture (third edition) from page 794 can be found below:
A short list of benefits of scripting:
I would suggest you look into adding scripting functionality as this would be a better solution to your problem. There are many scripting related questions on gamedev.stackexchange to get you started!
Yes, you can (and in my opinion should!) use the Visual C++ compiler. It is currently one of the best compilers out there.
Furthermore, while it is very interesting to write your own compiler, it's not very wise to use it for speed-critical applications like games.