How to write Cross Platform Application using C++

Dear Sir,

We need to develope an application which should be platform independent or cross platform application (Linux ,windows & other platfrom)using c++ language.

our application should support multithreading, socket communication,file handling,database operation, dynamic load library or shared object and STL.

We also what to know any coding standard available for cross platfrom application in c++

We already working in windows platform in vc++ 6.0
and very compatible with c++ concept



Thanking You,
Chandar Kumar V
What is your question ?
Cross-Platform Development in C++: Building MAC OS X, Linux, and Windows Applications covers Netscape's approach to platforms/feature sets. It may cover more than you need.
To Develope the cross platform application using C++ you have two option,

1. Identify all the platform specific functionality (basic functions) and create the abstract layer using macros for e.g if you want to write a function for creating delay and you want it to work on both linux and unix the code should be like this,

1
2
3
4
5
6
7
8
void CreateDelay(int Delaycount)
{
#if defined(OS_WIN32)
              Sleep(Delaycount);
#elif defined(OS_LINUX)
             usleep(Delaycount);
#endif
}


now write your make file in a way that it takes argument and define either "OS_WIN32" macro or "OS_LINUX" macro, and your program will compile for specific platform based on argument. similarly identify all functions which are platform dependent and define them in abstract layer (we call it virtual os layer). even you can write your own memory manager , thread scheduler and other critical functions (but that depends on what level of project you are working on).

2. the second option is simple one (rather critical) use the QT Framework to write your application. QT internally does the same thing and will make your application portable (almost!).
the advantage of using QT is it has big framework and gives good support for GUI as well, futher more QT is also available in embedded version so you can also run your application on embedded hardwares.

hope that's too much and sufficient for you to understand
Qt is not the only choice for such a thing. (Personally, I think it is the nicest choice, but it is also a fairly expensive choice.)

Google around "C++ cross-platform application frameworks" for more.

Good luck!
how about boost... it will be part in the next c++ standard...
closed account (1yR4jE8b)
C++ itself for the most part is platform agnostic, it just needs to be compiled seperately on each platform.

For GUI development, QT is the nicest I've ever used and takes very good advantage of many of C++'s nice features (templates, inheritance, etc...). But like the core language, the code needs to be recompiled on each machine.

But there are always corner cases that you need to deal with on any platform.
Topic archived. No new replies allowed.