Cross Platform

I did some programming in VBA, now I trying to learn C++

Can I use C++ to create cross-platform?
Does the cross-platform depends on the on the language or on the compiler?
closed account (1yR4jE8b)
Standard C++ is platform agnostic. Cross platform compatibilty basically depends on your program being conformant to different compiler implementations of the C++ standard so you can compile your code on any operating system. The easiest way is to use a cross-platform compiler such as GCC.

GCC is the standard compiler on most Linux distributions, so you can install it with the distro's package manager. On windows you can either manually install it (which I don't recommend for beginners), or you can download an IDE that bundles it.

I recommend either Code::Blocks, or Orwell Dev-C++ for beginners.
Well, yes and no.

No in terms of - you cannot create a program that you will compile and then be able to run on every platform, because the compiled executable will contain the platform-dependent instructions and calls to platform-dependent libraries.

However, you can write platform-independent code. That means that you can write some code that you will be able to compile and then run on different platforms. Plain C++ is essentially cross-platform. Also you can use cross-platform libraries, such as Qt (which hides a lot of platform-dependent code behind a platform-independent interface).

So, overall, yes - you can write code that you will only need to compile to have it run on any platform. And no - you cannot create a "packaged" (like a jar) version that you will be able to run everywhere.
thank you brothers, really able to appreciated and i like it
Your source code is what needs to be cross-platform. There are different ways of doing that, (such as #ifdef and #ifndef) based on the Operating System (which can get very difficult to read). The easiest way is just writing source code that is 100% portable to different platforms. It is easiest because there will be less source code and it will be simple to read. Sometimes, this will take some research, but distribution of the source code is all that is needed afterwards.
Topic archived. No new replies allowed.