【问题标题】:gnuplot-iostream not linking to boostgnuplot-iostream 未链接到 boost
【发布时间】:2012-04-09 15:48:20
【问题描述】:

您好,我正在尝试使用 gnuplot-iostream,目前我只是想让代码 here 工作。当我尝试合并时,链接器中出现错误:

In function `stream<int, boost::iostreams::file_descriptor_flags>':
/usr/include/boost/iostreams/stream.hpp:130: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(int, boost::iostreams::file_descriptor_flags)'

In function `boost::iostreams::file_descriptor_sink boost::iostreams::detail::wrap<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink const&, boost::disable_if<boost::iostreams::is_std_io<boost::iostreams::file_descriptor_sink>, void>::type*)':
/usr/include/boost/iostreams/detail/wrap_unwrap.hpp:53: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(boost::iostreams::file_descriptor_sink const&)'

In function `concept_adapter':
/usr/include/boost/iostreams/detail/adapter/concept_adapter.hpp:67: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(boost::iostreams::file_descriptor_sink const&)'
/usr/include/boost/iostreams/detail/adapter/concept_adapter.hpp:38: undefined reference to `boost::iostreams::file_descriptor_sink::file_descriptor_sink(boost::iostreams::file_descriptor_sink const&)'

In function `long boost::iostreams::detail::write_device_impl<boost::iostreams::output>::write<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink&, boost::iostreams::char_type_of<boost::iostreams::file_descriptor_sink>::type const*, long)':
/usr/include/boost/iostreams/write.hpp:121: undefined reference to `boost::iostreams::file_descriptor::write(char const*, long)'

In function `void boost::iostreams::detail::close_impl<boost::iostreams::closable_tag>::close<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink&, std::_Ios_Openmode)':
/usr/include/boost/iostreams/close.hpp:224: undefined reference to `boost::iostreams::file_descriptor::close()'

In function `std::fpos<__mbstate_t> boost::iostreams::detail::seek_device_impl<boost::iostreams::any_tag>::seek<boost::iostreams::file_descriptor_sink>(boost::iostreams::file_descriptor_sink&, long, std::_Ios_Seekdir, std::_Ios_Openmode)':
/usr/include/boost/iostreams/seek.hpp:137: undefined reference to `boost::iostreams::file_descriptor::seek(long, std::_Ios_Seekdir)'
collect2: ld returned 1 exit status

注意我已经安装了 boost 并且以前编译过使用 iostream 的程序。 任何帮助都非常感谢。谢谢

【问题讨论】:

    标签: c++ gnuplot


    【解决方案1】:

    排除明显的...您是否使用g++ -lboost_iostreams 进行编译?如果您可以分享一些有关如何调用编译器和链接器的信息,它将更容易回答您的问题。

    【讨论】:

    • 我不确定,我正在 Eclipse 中构建。当我查看 gcc c++ 编译器的设置时,它会在所有选项框中显示命令 g++ -I/usr/include/boost -O0 -g3 -Wall -c -fmessage-length=0。 Binary Parser 是 Elf,error Parsers CDT,工具链是 Linux GCC,当前 builder 是 GNU make Builder。如果您需要更多信息,请询问,最好让我知道在哪里可以找到它。对不起,如果有些东西是多余的。我喜欢编程,但在构建/编译方面并不是最迷茫的。
    • 我不熟悉 eclipse,但我知道-I/usr/include/boost 只告诉编译器在哪里可以找到 boost 标头。它不会告诉链接器在哪里可以找到 boost 库。看看是否有办法让 eclipse 将-lboost_iostreams 添加到编译器参数列表中。
    • 太棒了,通过将 boost_iostream 添加到 properties->c/C++ Build->Settings->GCC C++ Linker->Libraries(-l) 来解决。
    【解决方案2】:

    在尝试将 g++ 与 gnuplot-iostream 库一起使用时遇到了确切的问题。

    g++ prog.cpp -L/usr/lib -lboost_filesystem -lboost_system -lboost_iostreams
    

    为我解决了这个问题 - 代码编译成功,没有错误。

    【讨论】:

      猜你喜欢
      • 2016-09-17
      • 1970-01-01
      • 2010-09-20
      • 2012-11-06
      • 1970-01-01
      • 2017-05-21
      • 2017-05-15
      • 2011-05-28
      • 1970-01-01
      相关资源
      最近更新 更多