不能使用 Boost.process

Cannot use Boost.process

本文关键字:process Boost 不能      更新时间:2023-10-16

我下载并打包了 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>。我希望这有所帮助。