lnav icon indicating copy to clipboard operation
lnav copied to clipboard

undefined reference to pcrecpp::RE::GlobalReplace

Open bAndie91 opened this issue 4 years ago • 9 comments

lnav version

v0.9.0 commit 0e1eb41

Describe the bug

i'm compiling lnav and the following errors are generated while linking. it mostly complains on undefined reference to pcrecpp::RE::GlobalReplace(), but it's there in libpcrecpp.so. perhaps it did not find the correct .so?

see:

nm -CD /usr/local/opt/pcre_8.45/lib/libpcrecpp.so
…
pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::string*) const
…

relevant versions of dependencies:

  • gcc_5.1.0
  • autoconf_2.69
  • sqlite_3.36.0
  • pcre_8.45
  CXXLD  lnav
libdiag.a(help_text_formatter.o): In function `link_name(help_text const&)':
/src/lnav/src/help_text_formatter.cc:467: undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
libdiag.a(lnav_commands.o): In function `csv_quote_string':
/src/lnav/src/lnav_commands.cc:487: undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
libdiag.a(lnav_config.o): In function `install_from_git(char const*)':
/src/lnav/src/lnav_config.cc:196: undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
libdiag.a(readline_possibilities.o): In function `_ZL22add_text_possibilitiesP15readline_cursesiRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_.constprop.259':
/src/lnav/src/readline_possibilities.cc:163: undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
/src/lnav/src/readline_possibilities.cc:164: undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
libdiag.a(string-extension-functions.o):/src/lnav/src/string-extension-functions.cc:193: more undefined references to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const' follow
libdiag.a(textview_curses.o): In function `textview_curses::execute_search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/src/lnav/src/textview_curses.cc:452: undefined reference to `_ZN7pcrecpp2RE9QuoteMetaB5cxx11ERKNS_11StringPieceE'
yajlpp/libyajlpp.a(yajlpp.o): In function `json_path_handler_base::json_path_handler_base(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/src/lnav/src/yajlpp/yajlpp.cc:50: undefined reference to `_ZN7pcrecpp2RE9QuoteMetaB5cxx11ERKNS_11StringPieceE'
yajlpp/libyajlpp.a(yajlpp.o): In function `scrub_pattern':
/src/lnav/src/yajlpp/yajlpp.cc:61: undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
collect2: error: ld returned 1 exit status

To Reproduce

git checkout v0.9.0
./autogen.sh
export PATH=/usr/local/opt/gcc_5.1.0/bin:/usr/local/opt/autoconf_2.69/bin:/usr/local/opt/automake_1.16/bin:$PATH 
./configure --with-sqlite3=/usr/local/opt/sqlite_3.36.0/  --without-curl --with-pcre=/usr/local/opt/pcre_8.45/
make

bAndie91 avatar Jul 20 '21 22:07 bAndie91

Can you try building the latest version (v0.10.0) from source. I've removed this dependency because it's a bit of a pain.

tstack avatar Jul 21 '21 08:07 tstack

i'm compiling v0.10.0-beta1 bb35ac1 , now it fails in compile phase:

make[3]: Entering directory `/src/lnav/src/fmtlib'
  CXX    format.o
format.cc: In instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’:
format.cc:79:68:   required from here
format.cc:79:68: error: explicit instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’ but no definition available [-fpermissive]
     basic_format_args<FMT_BUFFER_CONTEXT(char)>, detail::locale_ref);
                                                                    ^
format.cc: In instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’:
format.cc:79:68:   required from here
format.cc:79:68: error: explicit instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’ but no definition available [-fpermissive]
format.cc: In instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’:
format.cc:79:68:   required from here
format.cc:79:68: error: explicit instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’ but no definition available [-fpermissive]
format.cc: In instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’:
format.cc:79:68:   required from here
format.cc:79:68: error: explicit instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’ but no definition available [-fpermissive]
format.cc: In instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’:
format.cc:79:68:   required from here
format.cc:79:68: error: explicit instantiation of ‘void fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<T>&, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char> >, fmt::v7::type_identity_t<Char> > >, fmt::v7::detail::locale_ref) [with Char = char; fmt::v7::type_identity_t<Char> = char]’ but no definition available [-fpermissive]
make[3]: *** [format.o] Error 1

where should it get libfmt headers from?

bAndie91 avatar Jul 21 '21 11:07 bAndie91

ok, please ignore my commend right above, i compiled fmtlib 7.1.3 separatly and copied the resulted format.o and os.o in, so this is no longer an issue. however it may not be the best version, because now it complains on something formating:

make[2]: Entering directory `/src/lnav/src/base'
  CXX    auto_pid.o                                                            
  CXX    date_time_scanner.o                                                   
In file included from date_time_scanner.cc:35:0:                               
../../src/ptimec.hh: In function ‘void ftime_i(char*, off_t&, ssize_t, const exttm&)’:
../../src/ptimec.hh:476:52: error: expected ‘)’ before ‘PRId64’                
     snprintf(&dst[off_inout], len - off_inout, "%" PRId64, t);                
                                                    ^                          
../../src/ptimec.hh:476:61: warning: spurious trailing ‘%’ in format [-Wformat=]
     snprintf(&dst[off_inout], len - off_inout, "%" PRId64, t);                
                                                             ^                 
../../src/ptimec.hh:476:61: warning: too many arguments for format [-Wformat-extra-args]
../../src/ptimec.hh:476:61: warning: spurious trailing ‘%’ in format [-Wformat=]
../../src/ptimec.hh:476:61: warning: too many arguments for format [-Wformat-extra-args]
../../src/ptimec.hh: In function ‘void ftime_6(char*, off_t&, ssize_t, const exttm&)’:
../../src/ptimec.hh:509:52: error: expected ‘)’ before ‘PRId64’                
     snprintf(&dst[off_inout], len - off_inout, "%" PRId64, t);                
                                                    ^                          
../../src/ptimec.hh:509:61: warning: spurious trailing ‘%’ in format [-Wformat=]
     snprintf(&dst[off_inout], len - off_inout, "%" PRId64, t);                
                                                             ^                 
../../src/ptimec.hh:509:61: warning: too many arguments for format [-Wformat-extra-args]
../../src/ptimec.hh:509:61: warning: spurious trailing ‘%’ in format [-Wformat=]
../../src/ptimec.hh:509:61: warning: too many arguments for format [-Wformat-extra-args]
make[2]: *** [date_time_scanner.o] Error 1                                     

i'm looking into it. perhaps PRId64 is undefined?

bAndie91 avatar Jul 21 '21 14:07 bAndie91

What OS are you building on? Maybe attach the config.log file that is generated by configure. I'm not clear why you would see any of these failures.

tstack avatar Jul 21 '21 20:07 tstack

weird. i put #define PRId64 "lld" in to unblock this error. then it failed on again on fmtlib-related code:

  CXX    humanize.network.o                   
In file included from humanize.network.cc:32:0:
humanize.network.hh: In member function ‘constexpr auto fmt::v7::formatter<network::locality>::parse(fmt::v7::format_parse_context&)’:                         
humanize.network.hh:52:5: error: expression ‘<throw-expression>’ is not a constant-expression
humanize.network.hh: In member function ‘constexpr auto fmt::v7::formatter<network::path>::parse(fmt::v7::format_parse_context&)’:                             
humanize.network.hh:80:5: error: expression ‘<throw-expression>’ is not a constant-expression

so I removed constexpr from the corresponding locations.

now, here is an even stranger one:

  CXX    log_format_loader.o                                        
In file included from log_format_loader.cc:48:0:
yajlpp/yajlpp_def.hh: In instantiation of ‘json_path_handler::for_field(Args ...)::<lambda(yajlpp_parse_context*, const unsigned char*, size_t)> [with Args = {logline_value_meta external_log_format::value_def::*, value_kind_t logline_value_meta::*}; typename std::enable_if<json_path_handler::LastIsEnum<Args ...>::value, bool>::type <anonymous> = 1u; size_t = unsigned int]’:
yajlpp/yajlpp_def.hh:729:33:   required from ‘struct json_path_handler::for_field(Args ...) [with Args = {logline_value_meta external_log_format::value_def::*, value_kind_t logline_value_meta::*}; typename std::enable_if<json_path_handler::LastIsEnum<Args ...>::value, bool>::type <anonymous> = 1u]::<lambda(class yajlpp_parse_context*, const unsigned char*, size_t)>’
yajlpp/yajlpp_def.hh:729:26:   required from ‘json_path_handler& json_path_handler::for_field(Args ...) [with Args = {logline_value_meta external_log_format::value_def::*, value_kind_t logline_value_meta::*}; typename std::enable_if<json_path_handler::LastIsEnum<Args ...>::value, bool>::type <anonymous> = 1u]’
log_format_loader.cc:492:49:   required from here
yajlpp/yajlpp_def.hh:737:59: error: expansion pattern ‘args#0’ contains no argument packs
                     (decltype(json_path_handler::get_field(obj,
                                                           ^

mine is Linux, packages mostly from Debian sources, but I usually compile everything from source and point dependencies to the required versions. so it does not really follows any distro's "latest" software versions. this altough may be a culprit here, say it finds incompatible deps, /usr/lib/… instead of the ones passed in --with-… parameters, or there is not even a --with-XY parameter for lib XY, or working with hardwired /usr/bin/… instead of looking up the PATH, or something like that.

could you, instead, please describe which dependency versions and lib versions are you compile against successfully? so i could setup my build environment accordingly. i suspect gcc 5.1 would not be latest enough.

bAndie91 avatar Jul 21 '21 23:07 bAndie91

where should it get libfmt headers from?

The headers are included in the lnav source tree.

perhaps PRId64 is undefined?

I think this is supposed to be in the inttypes.h system header, which is included in that file.

It seems like some issues with the compiler/headers being a bit out-of-date. Since your environment is non-standard, there's not much I can do to help. Usually, I would setup a vagrant VM to try to replicate issues like this, but there's not much I can do otherwise.

tstack avatar Jul 23 '21 18:07 tstack

what is the supported building environment? could you please describe it? i have PRId64 in system default inttypes.h from gnu libc6 2.13 (i386), but it strangely did not find it. anyway, i copied it in, so it's happy now. in the meanwhile I'm trying with gcc 8.5.0 and binutils 2.37…

bAndie91 avatar Jul 24 '21 22:07 bAndie91

OK I managed to compile with

  • gcc 8.5.0
  • binutils 2.37 (ld &al.) – 2.22 was not enough
  • others as above
  • PRId64 definition copied in from libc6 ver 2.13 inttypes.h
  • LDFLAGS=-L/usr/lib/i386-linux-gnu/
  • PATH=/usr/local/opt/binutils_2.37/bin:/usr/local/opt/gcc_8.5.0/bin:/usr/local/opt/autoconf_2.69/bin:/usr/local/opt/automake_1.16/bin:$PATH
  • ./configure --with-sqlite3=/usr/local/opt/sqlite_3.36.0/ --with-pcre=/usr/local/opt/pcre_8.45/ --without-libcurl
  • lnav version bb35ac1 (v0.10.0-beta1)

plus I had to change the RPATH in the resulted lnav binary to point to the right lib version's directories. i dont know which part should have set it, because I have specified them for ./configure.

RPATH = /usr/local/opt/gcc_8.5.0/lib:/usr/local/opt/sqlite_3.36.0/lib:/usr/local/opt/pcre_8.45/lib

anyway thanks for the help.

bAndie91 avatar Jul 24 '21 23:07 bAndie91

PS. I can not edit the ticket title, maybe worth to rewrite to something like "find out building environment requirements and build software versions" to reflect what actual it came to be about.

bAndie91 avatar Jul 24 '21 23:07 bAndie91