c++coutwinpe

No output from C++ program


First of all, sorry if this is in the wrong category, as I am not sure what the cause of this problem is.

For educational purposes I have created a small "Hello World" application

#include <iostream>
int main() {
    std::cout << "Hello World\n";
    return 0;
}

I have tried compiling it with both Visual Studio as well as MINGW-64(g++ -m64 main.cpp), as a 64-bit application. It runs perfectly on my Windows computer, but when I try to run it within the latest Windows PE it doesn't print out any thing. I have also tried with std::cin so that the program doesn't stop right away, but the same thing happens - no output and no error. enter image description here

I know WinPE is very limited in terms of included libraries and subsystems, but I really thought that this simple Hello World app would run. The WinPE environment is 64-bit, that 's why I am compiling as 64-bit

Any ideas where I should start?


Solution

  • I found the actual problem. I didn't compile the application statically which caused it to rely on dependencies not found in WinPE. I re-compiled it using the '-static' flag and it now works as expected on both WinPE and desktop versions of Windows.