开发者

What is meant by porting an application X to a platform Y?

开发者 https://www.devze.com 2022-12-25 17:24 出处:网络
Pretty clear from the title itself, what is meant by porting an application X to a platform Y? Say for 开发者_开发知识库example I have an application X running on some OS, say Y, What do I do to port

Pretty clear from the title itself, what is meant by porting an application X to a platform Y?

Say for 开发者_开发知识库example I have an application X running on some OS, say Y, What do I do to port this application to another OS say Z?

Does this mean rewriting a new application A for Operating system Z that necessarily imitates the behavior of application X on Operating System Y.

Please explain.


There isn't a precise method to do this. In some cases, a full rewrite is necessary. In others, it may be a matter of compiling for a different OS or processor. It really depends on the application, the source platform, and the target platform. Whatever works!


I agree with Peter.

"Porting", when said by non-technical types, usually means: "I want to use X on my system - how can I do this?" This may be as simple as copying the same code (say Java or .Net) and running it (ta da!), or it could be as complicated as taking X as the basis of a specification and rebuilding from scratch (full rewrite per Peter).

"Porting" for technical users usually refers to moving a piece of functionality from one system to another. It could be an operating system (OS), a framework (e.g. Java to .Net), a technology (e.g. Flash to JavaScript + CSS + xHTML)...

Either way, you need more information to provide a recommendation/solution.


Some programs, you might just be able to recompile for a new platform, no problems. If it's a very simple program, not using anything specific to that OS, you might be able to get away with this. Basically, taking the source, moving it to another OS, and using a compiler on there. Even if there is specific code, though, you could use compile-time flags, or constants in your code, to get the compiler to operate differently. I'm rusty on my C++ syntax, but I think this should show what I mean:

#if OS == WINDOWS
root = "C:\\";
#elseif OS == LINUX
root = "/";
#endif

Another method is to run the program inside a virtual machine, like Java. That VM would work on different platforms, and your executable should be able to run seamlessly across anything using it. You may have to do a recompile with a few small changes, if there was OS-specific code, but if you're intending from the start to port, then you likely wouldn't worry about this.

A third way is a combination of the two, and is, if I recall correctly, what Firefox does. Most of the code stays exactly the same, but it uses a base to run on, which is compiled specifically for that OS, that defines different things, creates specific types of variables, such as nsInt (been awhile since I've looked at FF code, so I'm likely wrong, but I know prepending ns is their convention) which you would use in place of int, as it would specifically be designed to be the same across platforms.

When you compile, the correct platform is chosen for the base, then the entire program is compiled using that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号