porting application across OSes

Programming, for all ages and all languages.
Post Reply
shaz

porting application across OSes

Post by shaz »

how can i port applications developed on say windows to linux.
should i write some sort of virtual machine.
what are neccesary things which i have to implement in this project.
Therx

Re:porting application across OSes

Post by Therx »

depends on what parts of the windows API it uses. If it's pure ANSI c then just recompile. If you use Winsock you have to change a few function names etc. for Unix sockets. If its a windowed program then I guess there is more involved (but I've never programmed for X so i don't know)

Maybe try Wine to see if you can run the windows procs on linux

Pete
shaz

Re:porting application across OSes

Post by shaz »

so it just requires conversion of system calls .
is there any way to change those system calls at runtime.
means that there is some sort virtual machine which converts the system calls accordingly and then exexutes that application.
Tim

Re:porting application across OSes

Post by Tim »

You can run plain Windows binaries on Linux using Wine, but that's not really porting anything. Porting refers to changing the source code from, say, Win32 calls to Posix calls, and recompiling on Linux.
dfg

Re:porting application across OSes

Post by dfg »

java ?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:porting application across OSes

Post by Solar »

shaz wrote: so it just requires conversion of system calls .
Only if the application in question is of a rather generic nature. As soon as an app makes use of any "special" OS functionality, porting it will become much harder. A good example are games.

There are those who use OpenGL, which is a generic graphics API. Porting those from one platform to another is a (relatively) easy task: You have to make adjustments, but all in all the application remains the same.

Then there are those who use DirectX - which is a technology proprietary to Microsoft. You will find it a taxing task to port this to any other platfom, because the whole architecture of the application in question is likely to revolve around the DirectX API.

Of course, a programmer could write an application in a way that it could easily abstract the actual API used - e.g. the game "IL-2 Sturmovic" allows to switch the rendering engine between OpenGL and DirectX - but unless the programmer had portability in mind right from the start, chances to find such a setup are slim.
is there any way to change those system calls at runtime.
Again, only for trivial applications. As soon as the issue becomes more evolved, chances are that it's not only the call in question, but the whole architecture surrounding it that has to be changed.

Picture this: You have two graphics APIs - let's call them OpenGL and DirectX. ;-) Both have a command to draw a circle, which is passed x, y, radius, color and a couple other parameters. Since the task at hand is very similar, chances are that a little rearranging of parameters and renaming of the function call itself will do the trick of "porting" the drawing of a circle from one to the other.

But most things are more delicate than this. Complex data structures might be fundamentally different. One solution might use shared memory where another uses sockets, etc. etc. - it's no longer a matter of shifting around a couple of parameters, you have to change concepts.
means that there is some sort virtual machine which converts the system calls accordingly and then exexutes that application.
From a certain level of complexity onward, you are usually better off trying to port the underlying technology instead of the application. Cygwin provides a POSIX environment including many common shell tools and an X server for Windows. Wine provides a Windows API emulation for Linux. Perhaps one of these two readily available solutions can help you.
Every good solution is obvious once you've found it.
Post Reply