ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What option should I use while compile to make cross-platform (this is the name, I guess) program files for using in both Linux & Windows platforms? How complex is it?
For example, I use c++ Hello.cpp -o Hello to compile the Hello.cpp by gcc-c++ to run in Linux pc. How can I make it for both 'Linux & Windows'
Actually, C++ definitely can be used to build cross-platform software, but most of the time you see this being done at a fairly low level, commensurate with say "the Linux kernel." The pragmatic problem that always comes up is the User Interface. There is no standardization on this.
Therefore, what you normally see being done is something like Java, which has "abstracted completely away" all of these environment-specific details and inserted a user-interface (GUI widgets, etc.) layer of its own devising ... which the language does undertake to support across a wide range of host platforms and environments. The host-specific language system itself works on bytecodes, not native machine instructions, and "compiled" programs are transportable among environments without recompilation. (Basically, the slight "overhead" is an acceptable and justifiable price to pay.)
All things considered, it's a strategy that works well in practice. (Java not of course being the only language-system that does it, nor that takes this general approach.)
Footnote: Some language-systems in this space are quite machine-specific. Microsoft's "C#" C-sharp compiler for dot-Net can be very expressive at a "bits and bytes" level if you want to be, and yet it all runs under the so-called "CLR" runtime environment.
Last edited by sundialsvcs; 09-26-2012 at 04:11 PM.
The pragmatic problem that always comes up is the User Interface. There is no standardization on this.
I'm not sure if I understand what you're saying.
There are many good cross-platform user-interface libraries for C++. However, "cross-platform" in C++ means that you can compile the source on, or for, a selection of target platforms (one platform per compile). It doesn't mean that you can compile it once, and then run the same binaries on multiple platforms.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.