简体   繁体   中英

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

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM