- 1 year ago
Is There any way so i can compile c++ program on linux and run it on windows?
Yes, it is possible to compile a C++ program on Linux and run it on Windows. Here's an approach you can follow:
Set up a cross-compilation environment: Install a cross-compiler toolchain on your Linux machine that targets Windows. The toolchain includes the necessary compilers, libraries, and headers to compile programs for Windows.
For example, you can use the MinGW-w64 toolchain, which provides a GCC compiler that targets Windows. Install it using your Linux distribution's package manager. For Ubuntu, you can run the following command:
arduinosudo apt-get install g++-mingw-w64
Write your C++ program: Create or write your C++ program on the Linux machine. Ensure that the code doesn't include any Linux-specific dependencies or system calls that won't be available on Windows.
Cross-compile the program: Open a terminal on your Linux machine and navigate to the