I don't actually know where to start and what keywords to use for searching more, but can we simply make a programs in C++ that runs in Linux as well as Windows. I guess we are talking about binary files. Does it change the style of programming or do I just have to compile them in different way? If I open a Visual Studio on my Windows machine and I start creating a simple application which shows a string "Hi. You just execute me." in C++. Does it run on both of machines? Is there something I have to know about?

closed as too broad by Michael Homer, techraf, HalosGhost, Julie Pelletier, Archemar Nov 23 '16 at 5:59

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is a general programming question that is off-topic here. Questions about cross-platform programming are (in general) on-topic on Stack Overflow, but you'd need to be more specific in what you were asking. – Michael Homer Nov 23 '16 at 4:46

i often use wxwidgets, this places a layer in the code that you work with, which at compile time replaces references to windows / gtk...

it does change the way you code as instead of using gtk class or windows.h class direct, you'll use wxwidgets classes which get replaced with appropriate ones at compile time.

this gets the "real feel", as the end result is an application that is 100% native, using native class and gui.

other options are stuff like mono, qt, java... these all have the goal of standardization through an additional layer carried over to the host OS. basically they have a platform that runs in any env, and you can run your application on this platform.

going back to wxwidgest and the code style, you will find there are some things that wxwidgets doesn't have a wrapper class for. for example serial com ports, and linux / windows handle this very differently. For this you'd have to double code (define code for windows and code for linux).

Not the answer you're looking for? Browse other questions tagged or ask your own question.