不能使用 Boost.process
Cannot use Boost.process
我下载并打包了 1.54.0 的 Boost 库版本。我做了所有事情,就像回答这个问题一样:如何在Visual Studio 2010中使用Boost。然后我从这里下载并解压缩 Boost.process:http://www.highscore.de/boost/process/并按照回答这个问题做了所有事情:如何编译 Boost.Process 库?.
我将持有者进程和 process.hpp 放入持有者提升中,将其他持有者进程放入库,并尝试使用 b2.exe 和 bjam.exe 与"--with-process"编译它,但得到"错误的库名称'进程'。
无论如何,我将库包含在我的项目中并输入以下代码:
namespace bp = ::boost::process;
int main()
{
std::string exec = "G:\Detect.exe";
std::vector<std::string> args;
args.push_back("--version");
bp::context ctx;
ctx.stdout_behavior = bp::silence_stream();
bp::child c = bp::launch(exec, args, ctx);
return 0;
}
当我运行它时,我收到一些错误:
1>c:boost_1_54_0boostprocessdetailpipe.hpp(129): error C2665: 'boost::system::system_error::system_error' : none of the 7 overloads could convert all the argument types
1> c:boost_1_54_0boostsystemsystem_error.hpp(39): could be 'boost::system::system_error::system_error(int,const boost::system::error_category &,const std::string &)'
1> c:boost_1_54_0boostsystemsystem_error.hpp(43): or 'boost::system::system_error::system_error(int,const boost::system::error_category &,const char *)'
1> while trying to match the argument list '(DWORD, overloaded-function, const char [54])'
1>c:boost_1_54_0boostprocessoperations.hpp(130): error C2039: 'filesystem_error' : is not a member of 'boost::filesystem'
1>c:boost_1_54_0boostprocessoperations.hpp(130): error C3861: 'filesystem_error': identifier not found
我该怎么办?
我也有类似的情况。
我从 https://svn.boost.org/svn/boost/sandbox/process/下载了非官方的Boost.Process库(修订版86799说该网站),并将其与Boost 1.55一起使用。然后只需将标题放在 Boost 包含文件夹中(我没有看到任何 *.cpp 文件,因此库似乎完全内联)。发现内容:
- /
process/operations.hpp(130): 'filesystem_error' 不是 boost::filesystem
的成员放入 operations.hpp 文件#include <boost/filesystem.hpp>
/process/detail/pipe.hpp(129): 'boost::system::system_error::system_error"
将函数调用附加到boost::system::system_category
,即它将变为boost::system::system_category()
。
/process/detail/win32_ops.hpp(329):'.size' 的左边必须有类/结构/联合
基本上模板是const char*
的,但功能是按原std::string
实现的。因此,我只是在函数的开头添加了类似std::string exe (exe_);
的代码(exe_是const char*
参数的新名称)。也许不是最好的解决方案,但我认为已经足够好了。
希望这有帮助。
Il'ya Zhenin,在pipe.hpp中,无论您在哪里使用"boost::system::system_category",请将其替换为boost::system::system_category()
。这将解决system_error问题。
要解决此问题filesystem_error请在 operations.hpp 标头部分添加#include <boost/filesystem.hpp>
。我希望这有所帮助。
- 理解boost::asio-async_read在无需读取内容时的行为
- Boost::process on Windows - with MinGW?
- 使用单独的参数调用"boost::process::system()"时,获取"execv
- Boost.Process - 从具有休眠循环的进程读取
- 保持 boost.process 在函数之外处于活动状态,该函数被调用
- 使用boost.process同时读取和写入孩子的STDIO
- BOOST PROCESS RUNTUN()和EXIT_CODE()线程安全
- 传递向量或论点以bubost :: process(boost :: fusion)
- 程序在使用异步的 Boost.Process 调用 std::future.get() 后挂起
- 如何在 boost.process 间共享内存中使用复杂结构"push_back"函数向量
- 如何使用 Boost.Process 0.5 运行命令行/终端实用程序
- 如何使用Boost.Process从'type'(窗口)获取跟踪?
- 如何在Boost.process 0.5中与进程同步交互
- 不能使用 Boost.process
- 希望有效地克服 Boost.Process 间共享内存中映射中键类型之间的不匹配
- Boost.Process wait_for_exit(child): crash?
- 如何初始化boost::process::child(boost-process0.5)
- Boost::process -如何使它只运行一个进程
- 如何使用从shell脚本调用的GDB运行程序,而shell脚本又通过boost::process从c++调用GDB
- 使用boost::process调用外部程序会导致调用程序挂起(Linux)