Is it bad form to use the GNU getopt in C++ programs? Is there a C++ specific alternative, or should I still just use getopt?
7 Answers
There is nothing wrong with using getopt. There are a multitude of object oriented alternatives floating around including Boost.Program_options, and classes in POCO, and ACE.

- 26,924
- 5
- 64
- 92
I don't know that there's anything wrong with using getopt. But you might want to look at Boost.Program_options.

- 60,987
- 18
- 112
- 174
Not at all, getopt
is perfectly fine in C++. The Boost::program_options require that the Boost library be installed, which many may not have.

- 4,843
- 32
- 47
-
Boost can be built as static libraries. Otherwise, you'd practically have to ship the dynamic libs with your project *anyway*. – greyfade Oct 24 '10 at 04:11
-
1I mean that the "devel" packages for many Linux distros may not include Boost by default. – greg Oct 24 '10 at 12:07
I like TCLAP (http://tclap.sourceforge.net/) the Templatized C++ Command Line Parser Library.

- 2,876
- 2
- 24
- 28
Try CLPP library. It's simple and flexible library for command line parameters parsing. Header-only and cross-platform. Uses ISO C++ and Boost C++ libraries only. IMHO it is easier than Boost.Program_options.
Library: http://sourceforge.net/projects/clp-parser
26 October 2010 - new release 2.0rc. Many bugs fixed, full refactoring of the source code, documentation, examples and comments have been corrected.

- 1,342
- 2
- 10
- 23