Linuxbrew / legacy-linuxbrew

:skull: This repository is defunct, because it has been split into https://github.com/Linuxbrew/brew and https://github.com/Linuxbrew/homebrew-core
http://linuxbrew.sh
Other
2.23k stars 296 forks source link

lnav: Depends on pcre --cxx11 #1055

Closed dochang closed 8 years ago

dochang commented 8 years ago

Please follow the general troubleshooting steps first:

You can erase any parts of this template not applicable to your Issue.

Bug reports:

Gist log: https://gist.github.com/fe6e35aa8a2d4b693b13adb3e19b261b

When I run brew install lnav, Linuxbrew fails and reports the following message:

Last 15 lines from /home/doc/.cache/Homebrew/Logs/lnav/02.make:
libdiag.a(readline_possibilities.o): In function `pcrecpp::RE::RE(char const*)':
readline_possibilities.cc:(.text._ZN7pcrecpp2REC2EPKc[_ZN7pcrecpp2REC5EPKc]+0x42): undefined reference to `pcrecpp::RE::In
it(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pcrecpp::RE_Options const*)'
libdiag.a(string-extension-functions.o): In function `find_re(sqlite3_context*, char const*)':
string-extension-functions.cc:(.text+0x290): undefined reference to `pcrecpp::RE::Init(std::__cxx11::basic_string<char, st
d::char_traits<char>, std::allocator<char> > const&, pcrecpp::RE_Options const*)'
libdiag.a(string-extension-functions.o): In function `regexp_replace(sqlite3_context*, int, Mem**)':
string-extension-functions.cc:(.text+0x445): undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const
&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
libdiag.a(sql_util.o): In function `attach_sqlite_db(sqlite3*, std::__cxx11::basic_string<char, std::char_traits<char>, st
d::allocator<char> > const&)':
sql_util.cc:(.text+0x3a3): undefined reference to `pcrecpp::RE::Init(std::__cxx11::basic_string<char, std::char_traits<cha
r>, std::allocator<char> > const&, pcrecpp::RE_Options const*)'
sql_util.cc:(.text+0x530): undefined reference to `pcrecpp::RE::GlobalReplace(pcrecpp::StringPiece const&, std::__cxx11::b
asic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
collect2: error: ld returned 1 exit status
Makefile:749: recipe for target 'lnav-test' failed
make[1]: *** [lnav-test] Error 1
make[1]: Leaving directory '/tmp/lnav20160407-17465-13aangc/lnav-0.8.0/src'
Makefile:463: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1
rwhogg commented 8 years ago

I have the same problem, but was able to fix it by specifying brew install lnav --cc=clang. Does that work for you?

If so, I think this might need some investigation around a possible fails_with for GCC.

rwhogg commented 8 years ago

Note that you can install clang from linuxbrew with brew install llvm --with-clang if you don't have it.

dochang commented 8 years ago

brew install lnav --cc=clang reports the same error.

rwhogg commented 8 years ago

After having switched to clang, I'm unable to reproduce this. I'm also able to install it (after installing a missing sqlite3 dependency, for which I'll make a separate pull request) when building on the Linuxbrew Docker image.

I apologize, but I do not have any further suggestions at the moment.

rwhogg commented 8 years ago

@sjackman, any ideas about this one?

sjackman commented 8 years ago

@dochang Hi, Desmond. Please report the output of

brew install llvm --with-clang
brew install lnav --cc=clang
brew gist-logs lnav
sjackman commented 8 years ago

If so, I think this might need some investigation around a possible fails_with for GCC.

Yes. fails_with :gcc => "5". For historical reasons, fails_with :gcc means GCC 4.2 (which makes me grumpy).

dochang commented 8 years ago

brew install llvm --with-clang causes high CPU usage and makes my laptop too hot to install clang by brew. I install clang by apt-get (Debian sid) instead.

Here is the gist-log of brew install lnav --cc=clang.

sjackman commented 8 years ago
  CXXLD    lnav
  CXXLD    lnav-test
/home/doc/.linuxbrew/Cellar/curl/7.48.0/lib/libcurl.a(libcurl_la-openssl.o): In function `ossl_connect_common':
openssl.c:(.text+0xde0): undefined reference to `SSLv3_client_method'
/home/doc/.linuxbrew/Cellar/curl/7.48.0/lib/libcurl.a(libcurl_la-openssl.o): In function `ossl_connect_common':
openssl.c:(.text+0xde0): undefined reference to `SSLv3_client_method'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:745: recipe for target 'lnav' failed
make[1]: *** [lnav] Error 1
make[1]: *** Waiting for unfinished jobs....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:749: recipe for target 'lnav-test' failed
make[1]: *** [lnav-test] Error 1
make[1]: Leaving directory '/tmp/lnav20160411-17474-j927xf/lnav-0.8.0/src'
Makefile:463: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1

https://gist.github.com/dochang/cfe6b5e49e620615a939ca0b76f6164d#file-02-make-L100

sjackman commented 8 years ago

This error is typical when mixing openssl headers from one installation and openssl libraries from another. Try

sudo apt-get remove libopenssl-dev
brew remove openssl curl lnav
brew install lnav
dochang commented 8 years ago

I can build with clang after removing libssl-dev. But building with gcc still fails.

gist-logs for brew install lnav.

sjackman commented 8 years ago

That's good news! When posting a gist, please quote the relevant lines and link to them.

https://gist.github.com/dochang/d2e4694264cbddffa076aed01f4ff077#file-02-make-L101

  CXXLD    lnav-test
lnav.o: In function `execute_search(lnav_view_t, std::__cxx11::lnav.obasic_string:< charIn,  functionstd :`:execute_searchchar_traits(<lnav_view_tchar,> ,std :std::__cxx11::allocator:<basic_stringchar<>char ,>  stdconst:&:)char_traits'<:char
>lnav.cc,: (std::allocator<char> > const&)':
lnav.cc:(.text+0x240e): undefined reference to `pcrecpp::RE::QuoteMeta[abi:cxx11](pcrecpp::StringPiece const&)'
.text+0x240e): undefined reference to `pcrecpp::RE::QuoteMeta[abi:cxx11](pcrecpp::StringPiece const&)'
collect2: error: ld returned 1 exit status
sjackman commented 8 years ago

Try

sudo apt-get remove libpcre-dev
brew install pcre lnav
dochang commented 8 years ago

I didn't install libpcre3-dev. There're only runtime libraries:

$ dpkg -l '*pcre*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                     Version           Architecture      Description
+++-========================-=================-=================-======================================================
un  libpcre-ocaml            <none>            <none>            (no description available)
ii  libpcre16-3:amd64        2:8.38-3.1        amd64             Perl 5 Compatible Regular Expression Library - 16 bit 
ii  libpcre3:amd64           2:8.38-3.1        amd64             Perl 5 Compatible Regular Expression Library - runtime
un  libpcre3-dev             <none>            <none>            (no description available)

gist-logs of brew install pcre lnav:

  CXXLD    lnav-test
lnav.o: In function `execute_search(lnav_view_t, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
lnav.cc:(.text+0x240e): undefined reference to `pcrecpp::RE::QuoteMeta[abi:cxx11](pcrecpp::StringPiece const&)'
collect2: error: ld returned 1 exit status
Makefile:745: recipe for target 'lnav' failed
make[1]: *** [lnav] Error 1
make[1]: *** Waiting for unfinished jobs....
lnav.o: In function `execute_search(lnav_view_t, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
lnav.cc:(.text+0x240e): undefined reference to `pcrecpp::RE::QuoteMeta[abi:cxx11](pcrecpp::StringPiece const&)'
collect2: error: ld returned 1 exit status
Makefile:749: recipe for target 'lnav-test' failed
make[1]: *** [lnav-test] Error 1
make[1]: Leaving directory '/tmp/lnav20160412-7877-1la5erd/lnav-0.8.0/src'
Makefile:463: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1
sjackman commented 8 years ago

It looks as though lnav is using C++11. If that's the case, then I believe pcre must also be built using C++11. Try this patch:

diff --git a/Library/Formula/pcre.rb b/Library/Formula/pcre.rb
index 08fd3b4..54d373b 100644
--- a/Library/Formula/pcre.rb
+++ b/Library/Formula/pcre.rb
@@ -22,6 +22,7 @@ class Pcre < Formula
   end

   option "without-check", "Skip build-time tests (not recommended)"
+  option :cxx11 unless OS.mac?
   option :universal

   fails_with :llvm do
@@ -33,6 +34,7 @@ class Pcre < Formula
   depends_on "zlib" unless OS.mac?

   def install
+    ENV.cxx11 if build.cxx11?
     ENV.universal_binary if build.universal?

     system "./autogen.sh" if build.head?
brew remove pcre
brew install pcre --cxx11
brew install lnav
sjackman commented 8 years ago

Also try brew install gcc

dochang commented 8 years ago

Great! Your patch works!

brew remove pcre
brew edit pcre     # apply the patch
brew install --build-from-source pcre --cxx11
brew install lnav

brew install gcc is unnecessary.

Now lnav has been installed! Thanks for your help!

sjackman commented 8 years ago

It's possible that lnav should

  depends_on "pcre" => "cxx11"
sjackman commented 8 years ago

Great! Glad to here that you got it working, Desmond.