Question:
What is the differnce between c++ on windows and linux and if I make a program in windows can it tun on linux?
anonymous
2008-02-14 10:34:57 UTC
Without something like wine if I create a programs in windows using c++ what do I have to change or do to get it to run on linux??
Four answers:
rwid
2008-02-14 10:39:32 UTC
Wine should help make your C++ application code cross-platform compatible. If you're not making an OS-specific call somewhere, just recompile. Also, you'll want to stick with Posix-compliant routines as well. Unless your application is console-based (i.e. command line), you'll need a library to provide cross-platform support such as SDL or OpenGL.



If this type of library isn't an option, you need to port each GUI interface call to a Linux (X-Windows) equivalent. Obviously, porting can be a real headache and a lot of work (e.g. major rewrite).
Musaul
2008-02-14 11:46:57 UTC
From your question I can't tell how much you know about programming, so apologies if you think I'm going too basic with my answer.



When you compile a c++ program, it churns out a binary file that you can run directly. You can run it only on the platform it was compiled in e.g. a program compiled in linux will not run in windows, and vice versa. This is because different operating systems are not compatible at the binary level. Wine is a program that lets you get around that to a degree, as in it lets you run some windows programs in linux.



Now, that doesn't mean that a program written in c++ can't be compiled in a different platform to be run there. This is definitely possible. There are however restrictions, as in you have to avoid using any OS specific functions or libraries. For example if your program uses any win32 system calls or uses MFC etc., it will not compile on linux.



It is easy enough to avoid using os-specific libraries if you are writing a console application, but if you are writing a GUI application it can be tricky. Until .NET came out, almost all GUI desktop apps in windows were written using MFC (games are an exception).



What you can do though, is use a cross-platform GUI library such as:

wx-widgets - http://www.wxwidgets.org/

or QT - http://trolltech.com/products/qt



If you write your app using one of those, it will compile on any OS supported by them (provided you don't have any other OS-specific code of course).



It is generally also good practice to avoid using platform specific features unless you really need to. The STL and BOOST provide plenty for most type of programs.
?
2016-10-19 03:08:12 UTC
the convenience in upgrading application and hardware on a Mac is a few distance extra desirable to any laptop. the laptop theory of "plug and play" isn't something extra desirable than a farce. I even have by no ability seen a pc have any variety of hardware improve and not utilising a important fiasco ensuing- no count what kind CPU or hardware you're installation on it. With maximum classes obtainable on the two structures, the soundness of the Mac OS and the relative protection from viruses on the Mac make it the ideal determination. Granted, computers might certainly be ultimate for Microsoft place of work form classes, accounting, unfold sheets and video games, you won't have the ability to conquer the Mac for the domicile person who needs to get entry to pictures, music, the information superhighway, and so on. Spend the extra $$ and circulate with the Mac.
incantius
2008-02-14 10:37:32 UTC
just recompile the program on the linux box if it doesn't work with the version on windows.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...