If I write a C++ program and compile it into an executable file AND, don't have to install the program, will I have trouble running that C++ written program on other platforms? Do portability issues accross different platforms only arise when I have to install the program?

I'm currently breezing through a book called Portable C++ though I'm only building a stand-alone C++ program which will use WXWidgets (which is cross platform) though I'm not sure if this is necessary.

Do I still have to address portability issues even when building a stand-alone app (executable from a flash drive) where nothing is installed and I'm not accessing system files.

Thanks to anyone who can shead shome light on this.
Danny2000

If all you are using is the exe file you should be okay. You will still have the issue that the code was compiled for a particular implementation like windows running on an x86 chip. There could also be subtle bugs in your code that don’t show up on your system but will cause issues on other systems. To me portability is more about the code itself than the executable you produce. IMHO portable code should be code that will compile without issue on any standard compliant compiler.

If I write a C++ program and compile it into an executable file AND, don't have to install the program, will I have trouble running that C++ written program on other platforms?

Yes, you probably will. The executable itself is specific to the operating system and chipset where you built it. For example, if you try to run a Windows executable on Linux without an emulation layer like Wine, it'll fail.

Portability at the code level is about compilation, not execution. If your code is 100% portable, you should be able to rebuild it on any platform with a compiler and not encounter errors. There are also degrees of portability; it's difficult to write a completely portable program, but you can make porting the code easier by segregating the non-portable parts.

At a higher level you have things like byte code portability (a la Java) where the code is compiled into an intermediate byte code that's subsequently run by a virtual machine. The compiled byte code can be executed on any platform that supports the virtual machine, and the end result is close to full executable portability.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.