Running linux gcc-compiled program under windows

Ok guys, I hope this is a pretty simple question: is there a way to run a C program compiled under Linux using gcc on a Windows operating system? Please do not tell me to recompile it under windows, as I already tried, but it seems that the cc compiler does not have a 128-bit native type, and using the bignum libraries makes my program about 10-100 times slower. Is there a way to actually run a linux file under windows? Someone told me something about cygwin, but I don't know where to start. (My program must also be portable, so I do not need to install programs and stuff on my machine).

Many thanks! Matteo

+6
source share
5 answers

There is no direct way. The Linux executable file has a completely different format than Windows. There are several more options.

  • Cygwin. Compile the program using GCC under cygwin. I believe that I will build a Windows exe that uses the cygwin compatibility level.

  • install VM as VBox. Install Linux in VBox. Run the program there.

  • http://www.andlinux.org has the basis for this. I have never tried, but there is a video tutorial http://www.youtube.com/watch?v=nULDHPCm9p4 .

+8
source

Please do not tell me to recompile it under the windows

You will have to recompile it under Windows. Sorry!

If you really can't find a compiler that supports 128-bit integers, you should use some assembler to replicate the instructions that the Linux compiler emits.

+3
source

It seems to me that flinux can do this.

From the description:

... is a dynamic binary translator ... capable of running unmodified Linux binaries on Windows ...

Note. I have not tested this.

+3
source

Use the Linux virtual machine as a guest OS on your Windows OS. Run the executable file under the virtual machine. But it is best to compile for the gcc-cygwin combination.

0
source

Starting with the Windows 10 Anniversary Update, Windows can run Linux executables using Windows Subsystem for Linux (WSL), commonly called Bash on Ubuntu on Windows .

See https://msdn.microsoft.com/en-us/commandline/wsl

After installation, you can open a bash session, go to /mnt/<driveletter>/<path to your program> and run the executable as if you were running Linux.

Note. WSL is still in beta.

0
source

Source: https://habr.com/ru/post/891351/


All Articles