繁体   English   中英

将错误与升压过程(和其他升压库)链接

[英]Linking error with boost process (and other boost libs)

这是我的代码。 我只是在测试Boost :: process,所以我可以在需要的时候使用它。 我不知道为什么会收到链接错误。 我是一位相当新手的C ++程序员。 我知道这些概念,但是在实践中经常犯错误,并且调试不善。 我很感谢我对此提供的任何帮助。

#include<iostream>
#include<boost/process.hpp>
#include<boost/iostreams/device/file_descriptor.hpp>

namespace bp = ::boost::process;
namespace bpi = ::boost::process::initializers;
namespace bio = ::boost::iostreams;

int main(int argc, char *argv[])
{
  bp::pipe p = bp::create_pipe();
  bio::file_descriptor_sink sink(p.sink, bio::close_handle);

  bp::execute(
          bpi::run_exe("/usr/bin/ls"),
          bpi::bind_stdout(sink)
          );
  return(0);
}

这是我的错误...

/tmp/cc7cmrV8.o: In function `main':
test.cpp:(.text+0x2b): undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(int, boost::iostreams::file_descriptor_flags)'
/tmp/cc7cmrV8.o: In function `boost::process::posix::initializers::bind_stdout::bind_stdout(boost::iostreams::file_descriptor_sink const&)':
test.cpp:(.text._ZN5boost7process5posix12initializers11bind_stdoutC2ERKNS_9iostreams20file_descriptor_sinkE[_ZN5boost7process5posix12initializers11bind_stdoutC5ERKNS_9iostreams20file_descriptor_sinkE]+0x2b): undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(boost::iostreams::file_descriptor_sink const&)'
/tmp/cc7cmrV8.o: In function `void boost::process::posix::initializers::bind_stdout::on_exec_setup<boost::process::posix::executor>(boost::process::posix::executor&) const':
test.cpp:(.text._ZNK5boost7process5posix12initializers11bind_stdout13on_exec_setupINS1_8executorEEEvRT_[_ZNK5boost7process5posix12initializers11bind_stdout13on_exec_setupINS1_8executorEEEvRT_]+0x18): undefined reference to `boost::iostreams::file_descriptor::handle() const'
collect2: error: ld returned 1 exit status

平台:Linux 64位
提升:1.55(通过pacman安装)
Boost ::过程:0.5
编译命令: g++ -Wall test.cpp -o spegh.elf -lboost_system

一个简单的搜索就把我-This-

看到您发布了编译命令,我猜您只是在链接器设置中缺少-lboost_iostreams

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM