Firstly, are you sure these are the only lines of code in the file? If this is the case, then consider checking what C++ compiler does JUCE support (and check whether the compiler you have is compatible with that JUCE version, or whatever), as I have not yet checked that. Perhaps it is JUCE that is causing the project to not build by altering the behavior somewhere.
The code works perfectly, and I have just reproduced the working sample of this, try it here,
C++ Shell[
^]—not using JUCE framework but just mimicking the stuff around.