简体   繁体   中英

How to convert a linux executable file (binary) to windows exe file?

Is there any way to convert a Linux binary file to windows exe file? For example if in Linux create a very simple binary file like this:

echo "main(){int i; i=i+1;}" >> main.c

gcc main.c -o main

Is there any way to convert main binary file to a windows exe file?

You can not convert a linux executeable into a windows executeable. But you can compile the source with cross-compiler.

Eg: MinGw32

if you are in ubuntu:

sudo apt-get install mingw32
i586-mingw32msvc-cc main.c -o main.exe

There are no means to convert the binary.

Regular ways to go are:

  • Recompile for other platform, but this requires the source (and cross-platform support in the source or the used libraries must be available on the other platform as well). cygwin / mingw , for example, can help providing the required support/libraries.

  • wine could be used to run Windows binaries on Linux (but not the other way around)

If you have the lastest windows 10. Just install linux subsystem in the appstore. you can run whatever linux binary in windows you want

If you need to run your code/app/program in linux/mac/windows under another OS (linux to win or reverse exc..) but you don't want to use virtual machines or wsl systems you can use docker. Here is link: https://www.docker.com But you will need to learn first. What Is Docker? Docker is similar in concept to Virtual Machines, except it's much more lightweight. Instead of running an entire separate operating system (which is a massive overhead), Docker runs containers, which use the same host operating system, and only virtualize at a software level

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM