Vedmurty Vedmurty - 2 months ago 37
C++ Question

Running an exe on Windows that was cross-compiled on Linux

Aim: Cross-Compile a cpp code on Linux and execute it on Windows.

  • Native System : Ubuntu 14.04 (64bit).

  • Compilation Env on Native : mingw-w64

  • Target System : Windows 10 (64 bit)

  • Running Env on Target : cygwin

After looking around through a bunch of stuff, I installed mingw-w64 on the Linux and generated a helloWorld.exe file using the mingw-w64-g++.
This compilation was successful. When running the helloWorld.exe on Windows, it initially gave an error of libstdc++-6.dll missing.
On adding the path to the DLL from the MinGW installation on Windows into the PATH variable, the exe runs and terminates without any output.
It exits with error code 127 [Command Not Found].

I looked at several search results obtained from the "Questions that may already have your answer" suggestions, but none had the exact question.


I think the problem originated from PATH variable (directory where mingw64 installed) Sometimes people confuse \bin folder. It should be "C:\Program Files\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64\bin" not "C:\Program Files\mingw-w64\bin"