How can I compile C++ code and link it to a running program?

I have a program with an interface where the user can write code. Is there anyway I could compile, link and execute this code in the actual running program?