I am looking to create a small cross platform software using only c++ and i have no clue how to do it.
I tried to google it but all i can find is suggestions about using Qt, boost etc etc which i cannot use.
So can anyone provide me a small code example which can run on both Windows and Mac
I tried referring to Cross-Platform Development in C++: Building Mac OS X, Linux, and Windows Applications
but it seems to be very complex. i mean it talks about design patterns and other high level stuff but nothing to begin .... Like i want a starting point - a kind of template that is a basic structure to use, basic includes to use when developing a cross platform software.
Like i need a starting point.
Any help will be highly appreciated
I am not an expert on this but i have done some cross platform programming so here is what I learned. First, use only standard c++ and stay away from any commands that are specific to one compiler. Second, do not use any stuff that obviously depends on the OS, like system calls or using the windows API. Third, use some kind of automated build system like CMake, so that people can make projects and solutions on different systems. Fourth, use only libraries that are in standard c++ and that are known to work on all your target platforms.
Also I found it helpful to try out if the program works on other OS'es on a regular basis-not when finished writing the code but during the development process.I used a virtual machine for that.
I hope this helps.
Why do you say you cannot use boost or Qt ??
actually I think that in the measure in which it is possible, you should try to avoid constructions like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
// Mac Includes Here
// Linux Includes Here
#error Can't be compiled on Linux yet
#ifdef _WIN32 || _WIN64
// Windows Includes Here
#error Can't be compiled on Windows yet
because it limits the number of platforms on which you can build. There is a limited number of functions which require you using these preporcessor commands (like "sleep" on windows which is "usleep" on linux), but it is much better if you can avoid them so that you don´t need these "ifdef"'s.
I will see if I have time later this day to post you the example you want.
I tried referring to Cross-Platform Development in C++: Building Mac OS X, Linux, and Windows Applications but it seems to be very complex. i mean it talks about design patterns and other high level stuff but nothing to begin .... Like i want a starting point
I would have thought that "Item 2: Code from a Common Codebase" would have made a good starting point. It gives you the basics of what you will need to be doing.