Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practices for a C++ portable opensource application [closed]

I am starting an open source cross platform project in C++. My development environment is Linux. There may be other developers who develop from different platforms as well. So I need some help in getting started with the configuration and development environment setup, so that all developers from multiple platforms can develop easily.

Following are my questions

  1. Compiler : I plan to use g++ and heard that it is cross platform. Is that a good choice?
  2. Make files : I have seen Code::Blocks editor and it generates make files on fly and you don't have to write one manually. Is this the best practice or do I need to create make files?
  3. What are the other settings to be taken care when developing cross-platform applications?

Any thoughts?

Edit

Thanks for the answers. One more question.

Do you create makefiles by hand? Or is there any tool which can generate it?

like image 453
Navaneeth K N Avatar asked Mar 26 '09 03:03

Navaneeth K N


1 Answers

The most important thing for your project to catch up is portability. It should be easy to build & run for everybody.

GCC (g++) is indeed the compiler of choice. It comes from the opensource world and is therefore most widely adopted by it.

However, a simple Makefile won't cut it. Generating it using CodeBlocks or any other IDE has a problem: Due to their platform, other developers will probably have to generate their own, but won't necessarily have CodeBlocks at hand, or just don't want to use it.

There exist several different cross-platform build systems, which are IDE-agnostic. Some of them create Makefiles, others don't use make but build on their own.

  • The most widely adopted build system is Autotools. However, it is hard to learn, cluttered, and an overall pain in the ass.
  • Out of many other choices, I recommend Waf. It is proven by several larger open source projects already, XMMS2 being a good example (while not a very popular project, it has a large build with a lot of plugins and builds on a lot of platforms including OS X and Windows). While waf is not very broadly adopted, it is meant to be shipped with the source and easy to set-up. My recommendation for you.

Edit: to get started with your Open Source project, I also recommending this book by Karl Fogel (available for reading online). Have fun!

like image 151
ypnos Avatar answered Sep 19 '22 04:09

ypnos