-1

In windows we publish application in .exe format, so I have C program and I want to publish that application for linux. In which format I should publish it and how?

13
  • Publish an application for Linux or to run it from BIOS? Those are entirely different things and export formats. Commented Feb 9, 2023 at 10:36
  • @NikitaKipriyanov tell me about application for linux. Commented Feb 9, 2023 at 10:41
  • "Publish"? Do you mean compile?
    – Panki
    Commented Feb 9, 2023 at 10:46
  • 3
    What do you mean by “exporting”? Is this still within the context of providing your program in an initrd? Commented Feb 9, 2023 at 11:15
  • 3
    You have to not to "export it with specific extension" but to compile and link it to the target environment. In the initramfs of Linux the environment is pretty special, so you'll likely end up with static binary (that doesn't require dynamic libraries) or you will need to bring them together with an executable. Commented Feb 9, 2023 at 11:41

1 Answer 1

4

Main binary format that Linux uses is called ELF, originally it was invented for Unix. ld program can produce (link) them from object files. Linux can also support different executable formats; it's possible to write a custom loader which will load Windows's "exe" (Portable Executable) files and run them.

By the way, ".exe" is not a format, but a file name extension. It used to have at least two different formats from Microsoft: older DOS "MZ" format and more recent Windows PE format. Not only "exe" files have PE format; "dll" (dynamic libraries) have in principle the same structure, and many other files. Likewise, in Linux not only call-in binaries have ELF format, but shared dynamic libraries too, but usually those have ".so" as an extension, or ".so.1.3.4" (versioned form, digits represent the version of the library). Binaries that you call usually have no extension; the property to be an executable program comes from the file system attribute "executable", and is not inferred from the file name (extension).

However, the question is very broad. Try searching "linux c programming tutorial" to have a grasp what's the process of producing a binary executable looks like and then ask more concrete questions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .