5

Is it possible to have single standalone executable to be able to run on both linux and windows? It doesn't have to be from one binary code. I have no problem compiling linux version with gcc, windows one with mingw and then "merging" them. Is something like this possible?

I guess question is if it's possible to write both PE and ELF into one file. Or if there is some basic scripting thing both linux and windows understand.

graywolf
  • 7,092
  • 7
  • 53
  • 77
  • 1
    Does it have to be a compiled executable containing machine code? You can write portable programs in Java, Python, etc. – Wyzard Apr 19 '17 at 17:31
  • 1
    well I guess my main point is that I want single file to download from internet. so in the case of interpreted languagues, I would need to pack both linux and windows interpret into it – graywolf Apr 19 '17 at 19:38
  • 2
    In practice, people are so used to downloading the specific installer for their operating system, that you may find having a single cross-platform installer causes more confusion than it avoids. :-) – Harry Johnston Apr 20 '17 at 04:51
  • Maybe it's better to hybrid `cmd` and `bash`. The first line `#!/bin/bash` would be simply printing a error message in cmd. – recolic Dec 15 '20 at 07:42

1 Answers1

-1

From a compilation (C, C++, etc.) standpoint, no there isn't. There are always interpreted(scripting) languages like Python and Ruby that can be run on all platforms. Then there's Java, which can be run everywhere (theoretically). Also, bash scripts and I think linux executables can be mostly run by using cygwin or MinGW on windows, but there is no native way with shell scripting.

Community
  • 1
  • 1
Carter Brainerd
  • 199
  • 2
  • 10