I know that there is a way with a boost::process::child as described here:
boost::asio::boost::asio::io_service ios;
std::future<std::string> data;
child c("g++", "main.cpp", //set the input
bp::std_in.close(),
bp::std_out > bp::null, //so it can be written without anything
bp::std_err > data,
ios);
ios.run(); //this will actually block until the compiler is finished
auto err = data.get();
Can this work when calling boost::process::spawn or do I have to use a boost::process::child to do so?
No that is not possible. It's implied in the documentation:
Maybe you can use
child::detach
instead?