9

I know about getopts and argp. I just looked in boost and they have program_options as a library for parsing command-line parameters.

I'm not exactly sure which one to use. I know getopts is POSIX, while argp isn't but that doesn't matter to me. What matters is ease of use. Can you recommend (pros/cons?) one. I'm open to other libraries too.

Anonymous
18.8k2 gold badges42 silver badges65 bronze badges
asked Apr 15, 2012 at 8:54
0

3 Answers 3

14

If you want something lightweight and easy to use, then you might be interested in TCLAP (header only, liberal license). (example)

Otherwise boost::program_options (also liberal license) provides virtually anything one could need. (example)

Finally if you are already using a framework/library (WxWidgets, Qt) that has some command-line argument handling then probably the simplest option is to stick with that framework.

answered Apr 15, 2012 at 9:07
Sign up to request clarification or add additional context in comments.

Comments

2

You could also use popt.

If you are using a graphical toolkit like Gtk (thru GtkMM if in C++) or Qt, each of these offer their own command line arguments parsing facilities.

Comments

1

glibmm has Glib::OptionContext. It's quite simple but does what most people need, in a standard way. It's not well documented, but here is an example that shows most of what it can do: http://git.gnome.org/browse/glibmm/tree/examples/options/main.cc

It wraps the GOptionContext C API in glib.

answered Apr 17, 2012 at 20:09

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.