0

Forgive my lack of expertise, but I'm wondering if a source code for an open source windows program can be compiled and its executable used on Linux (without Wine). In my case it's Ant Renamer, which I currently use with Wine (I was unsatisfied with the Linux alternatives, which lack some advanced functionalities or a GUI).

2
  • 1
    Compiled, probably. Linked, no. The thing that makes it a Windows program, and not a generic, portable program, is that the code will make numerous references to a Windows API.
    – chepner
    Commented Oct 12, 2017 at 20:13
  • In your case, it's a Delphi program, so it's totally NO. You can try to port it to FreePascal. If it was a C/C++ program you could have tried to compile it using winelib.
    – cylgalad
    Commented Oct 13, 2017 at 7:28

1 Answer 1

5

The short answer is no. A longer answer is usually not. It depends on what libraries the program relies on.

Depending on the language that the program is written in, the standard library shipped with the compiler or interpreter may include more or less functionality. C, a ubiquitous language in the sense that only extremely unusual platforms lack a C compiler, has a standard library that's pretty small. For example, it has a concept of file I/O, but not directories, and its user interface is limited to standard input, standard output and standard error. Anything else requires making assumptions on the operating system or using a third-party library. Some languages choose to stick to what C can do in its standard library, so that their standard library can run everywhere C runs.

Other programming languages provide more features in their standard library, and may have de facto standard third-party libraries that are portable at least between Unix and Windows. Portable not in the sense that the same library code runs on both, but in the sense that there's a Windows implementation and a Unix implementation, and a program that uses the library doesn't need to care which one is being used. For example, Python's standard library has interfaces to manage files and directories and comes with a few basic GUI libraries (not nearly as nice-looking or sophisticated as what can be done, but they're portable and relatively simple to use); in addition there are some more advanced portable third-party libraries.

Both Unix and Windows have many features that aren't available on the other system, or that work very differently. Graphical user interfaces work very differently. Some Unix libraries have been ported to Windows, but Windows's interfaces have not been ported to Unix. The Windows GUI code is more integrated into the operating system (Unix's GUI was designed in separate layers from the start), and it is proprietary code (the libraries that come from the Unix world are mostly open source), so they would be very hard to port to Unix: you'd basically have to run Windows in a virtual machine. Wine attempts to provide an independent implementation of the Windows libraries, but it's a very difficult job.

Ant Renamer is written in a Pascal dialect for which the tools were developed for Windows, namely Delphi. There was a Linux port at some point, but I don't know how successful it was. The GUI libraries, in particular, would have to be rewritten from the Windows interfaces to some Unix ones. The practical answer is that if Ant Renamer can be made to work on Linux, it would require significant effort, possibly more than writing it from scratch based on a precise description of its behavior.


For the sake of people who found this question in a search but had a different problem — you can use a Unix machine to compile source from a Windows program to run on a Windows machine, with a cross compiler such as mingw.

1
  • Lazarus is supposed to be a decent Delphi clone, capable of building quite a few Delphi applications on Linux (to run on Linux). For C/C++ cross-compilation to Windows, I’d recommend MinGW-w64 instead of MinGW. Commented Oct 13, 2017 at 18:40

You must log in to answer this question.

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