简体   繁体   English

是否有适用于C ++的跨平台命令行库?

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

To run a command line using C++, I always use system command. 要使用C ++运行命令行,我总是使用system命令。 However, I think this way is too error-prone since I only can parse a char* as argument without any other information. 但是,我认为这种方式太容易出错,因为我只能将char*解析为没有任何其他信息的参数。 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 . 看看Boost.Process It is still work in progress and is not part of the official Boost yet, but looks promising. 它仍在进行中,并不是官方Boost的一部分,但看起来很有希望。

QProcess from Qt does this in a cross-platform manner. Qt的QProcess以跨平台的方式实现这一点。

http://doc.qt.nokia.com/4.6/qprocess.html 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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