roxrook
roxrook

Reputation: 13853

Is there any cross-platform command-line library for C++?

To run a command line using C++, I always use system command. However, I think this way is too error-prone since I only can parse a char* as argument without any other information. So I'm looking for a cross-platform library that works well with command-line? Has anyone known one?

Thanks,
Chan

Upvotes: 4

Views: 584

Answers (2)

vitaut
vitaut

Reputation: 55554

Have a look at Boost.Process. It is still work in progress and is not part of the official Boost yet, but looks promising.

Upvotes: 4

Dat Chu
Dat Chu

Reputation: 11140

QProcess from Qt does this in a cross-platform manner.

http://doc.qt.nokia.com/4.6/qprocess.html

From the documentation above, the example usage is:

// some parent object
QObject * parent;

QString program = "./path/to/Qt/examples/widgets/analogclock";
QStringList arguments;
arguments << "-style" << "motif";

QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);

Upvotes: 2

Related Questions