无法使用Boost.process

Il'*_*nin 5 c++ boost

我下载并升级了1.54.0的Boost库版本.我做了一切就像回答这个问题:如何在Visual Studio 2010中使用Boost 然后我从这里下载并解压缩Boost.process:http://www.highscore.de/boost/process/ 并做了所有的回答这个问题:如何编译Boost.Process库?.

我把holder进程和process.hpp放在holder boost中,把其他holder进程放到libs中,并试图用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;
    }
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我得到一些错误:

1>c:\boost_1_54_0\boost\process\detail\pipe.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_0\boost\system\system_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_0\boost\system\system_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_0\boost\process\operations.hpp(130): error C2039: 'filesystem_error' : is not a member of 'boost::filesystem'
1>c:\boost_1_54_0\boost\process\operations.hpp(130): error C3861: 'filesystem_error': identifier not found
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

Rad*_*ado 10

我有类似的情况.

我从https://svn.boost.org/svn/boost/sandbox/process/下载了非官方的Boost.Process库(修订版86799表示该站点)并将其与Boost 1.55一起使用.然后将标题放在Boost include文件夹中(我没有看到任何*.cpp文件,所以lib看起来完全内联).发现了什么:

  • /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'的左边必须有class/struct/union
    基本上模板是const char*,但是函数是按原样实现的std::string.因此我只是在函数的开头添加了代码std::string exe (exe_);(exe_const char*参数的新名称).也许不是最好的解决方案,但我认为还不错.

希望这可以帮助.


Fai*_*sal 5

Il'ya Zhenin,在pipe.hpp中,你在哪里使用"boost :: system :: system_category"替换它boost::system::system_category().这将解决system_error问题.

要修复filesystem_error问题,请#include <boost/filesystem.hpp>在operations.hpp标题部分添加.我希望这有帮助.