无法使用Boost.process

时间:2013-11-11 13:32:00

标签: c++ boost

我下载并升级了1.54.0的Boost库版本。我在回答这个问题时做了一切:How to use Boost in Visual Studio 2010 然后我从这里下载并解压缩Boost.process:http://www.highscore.de/boost/process/并做了回答这个问题的所有内容:How to compile Boost.Process library?

我把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;
    }

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

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

我该怎么办?

2 个答案:

答案 0 :(得分:10)

我有类似的情况。

我从https://svn.boost.org/svn/boost/sandbox/process/下载了非官方的Boost.Process库(修订版86799表示该站点)并将其与Boost 1.55一起使用。然后只将标题放在Boost包含文件夹中(我没有看到任何* .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*参数的新名称)。也许不是最好的解决方案,但我认为还不错。

希望这有帮助。

答案 1 :(得分:5)

Il'ya Zhenin,在pipe.hpp中,您使用“boost :: system :: system_category”将其替换为boost::system::system_category()。这将解决system_error问题。

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

相关问题