[Bug c++/105671] New: Unexplained "undefined reference" error

christian.morales.vega at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri May 20 10:06:25 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105671

            Bug ID: 105671
           Summary: Unexplained "undefined reference" error
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: christian.morales.vega at gmail dot com
  Target Milestone: ---

Created attachment 53005
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53005&action=edit
Full verbose build log

I have found a strange issue in my project build that reproduces is Ubuntu
22.04 (gcc 11.2) and Fedora 36 (gcc 12.1.1). This is the most I have been able
to reduce it:

$ tar xf boost_1_79_0.tar.bz2 
$ cd boost_1_79_0/
$ ./bootstrap.sh
$ ./b2 --with-program_options link=static --user-config=$PWD/../user-config.jam
$ cd ..
$ g++ -o /dev/null test.cpp -Iboost_1_79_0
boost_1_79_0/stage/lib/libboost_program_options.a -Os -flto
/usr/bin/ld: /tmp/cccbpRrv.ltrans0.ltrans.o: in function
`boost::program_options::options_description::get_option_column_width() const':
<artificial>:(.text+0x28cd): undefined reference to
`std::__cxx11::basic_stringbuf<char, std::char_traits<char>,
std::allocator<char> >::_M_high_mark() const'
/usr/bin/ld: /tmp/cccbpRrv.ltrans0.ltrans.o: in function
`boost::program_options::(anonymous namespace)::format_one(std::ostream&,
boost::program_options::option_description const&, unsigned int, unsigned int)
[clone .constprop.0]':
<artificial>:(.text+0x2d80): undefined reference to
`std::__cxx11::basic_stringbuf<char, std::char_traits<char>,
std::allocator<char> >::_M_high_mark() const'
/usr/bin/ld: <artificial>:(.text+0x2e13): undefined reference to
`std::__cxx11::basic_stringbuf<char, std::char_traits<char>,
std::allocator<char> >::_M_high_mark() const'
/usr/bin/ld: <artificial>:(.text+0x3d40): undefined reference to
`std::__cxx11::basic_stringbuf<char, std::char_traits<char>,
std::allocator<char> >::_M_high_mark() const'
collect2: error: ld returned 1 exit status
$

I'm attaching a log showing the whole Boost.Program_options verbose build log.

- Change "-Os" for "-O1" and it works
- Remove the -supposedly unused- "#include <boost/asio/spawn.hpp>" line and it
works.


More information about the Gcc-bugs mailing list