I just tried the -jit-kind=orc-lazy with lli executable and it solves the problem on Ubuntu 18.04 (still does not work on Windows 10). But this solution is good enough for me now. Thanks again for your help!
I have tried the same program but using stdio.h and printf(). It works fine on Windows.
But my use-case requires C++ support. I currently have a C++ text editor app in the App Store and I am working on adding on-device compilation and running capabilities (ideally). The reason for C++ support is because I believe there is a large community of people who are studying C++ in school and they would appreciate the convenience of entering and running their code on their iOS device.