akihikodaki / cld3-ruby

cld3-ruby is an interface of Compact Language Detector v3 (CLD3) for Ruby.
Apache License 2.0
77 stars 22 forks source link

Failed to locate protobuf #10

Closed alabeduarte closed 7 years ago

alabeduarte commented 7 years ago

Hi there,

I just saw a similar issue on bundler#5655 and I'm guessing this might be an issue with cld3 itself, could you help me on this?

This is what happens when I try to install the gem:

current directory: ~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/cld3-3.1.2/ext/cld3
~/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20170626-4596-1na0dfr.rb extconf.rb
Failed to locate protobuf
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=~/.rbenv/versions/2.4.1/bin/$(RUBY_BASE_NAME)
    --with-protobuf-config
    --without-protobuf-config
    --with-pkg-config
    --without-pkg-config

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  ~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/cld3-3.1.2/mkmf.log

extconf failed, exit code 1

Thanks in advance

akihikodaki commented 7 years ago

Read this at first and please tell me whether it gives a solution for your problem.

gem install cld3 triggers native library building. If it fails, you are likely to missing required facilities. Make sure C++ compiler and protocol buffers is installed. I recommend GCC as a C++ compiler. Ruby is likely to need pkg-config as well.

alabeduarte commented 7 years ago

Hi @akihikodaki

Thank you for the quick response.

I have installed GCC and pkg-config and yet I couldn't install cld3 gem. There is a specific version of GCC that is required to be installed? Follow below a few logs about my current environment:

gcc

▶ brew info gcc
gcc: stable 7.1.0 (bottled), HEAD
GNU compiler collection
https://gcc.gnu.org/
/usr/local/Cellar/gcc/7.1.0 (1,486 files, 283.8MB) *
  Poured from bottle on 2017-06-26 at 10:33:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gcc.rb
==> Dependencies
Required: gmp ✔, libmpc ✔, mpfr ✔, isl ✔
==> Options
--with-jit
    Build just-in-time compiler
--with-nls
    Build with native language support (localization)
--without-multilib
    Build without multilib support
--HEAD
    Install HEAD version

pkg-config

▶ brew info pkg-config
pkg-config: stable 0.29.2 (bottled)
Manage compile and link flags for libraries
https://freedesktop.org/wiki/Software/pkg-config/
/usr/local/Cellar/pkg-config/0.29.1_2 (10 files, 627.5KB)
  Poured from bottle on 2017-02-26 at 06:36:35
/usr/local/Cellar/pkg-config/0.29.2 (11 files, 627KB) *
  Poured from bottle on 2017-05-04 at 09:56:23
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pkg-config.rb

Thanks again!

akihikodaki commented 7 years ago

We seems to need to dig a bit more. What about following this instraction?

To see why this extension failed to compile, please check the mkmf.log which can be found here:

~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/cld3-3.1.2/mkmf.log

alabeduarte commented 7 years ago

Following the result:

▶ cat ~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/cld3-3.1.2/mkmf.log
"pkg-config --exists protobuf"
package configuration for protobuf is not found

I also checked the issue #3 but remove everything and reinstall didn't work for me.

Cheers

akihikodaki commented 7 years ago

@alabeduarte Have you installed protocol buffers? If you have, how did you install? (Did you use Homebrew?)

alabeduarte commented 7 years ago

Hi @akihikodaki

Thank you so much for the support, installing protobuf was the missing part to make it work.

Cheers!

mdf092 commented 6 years ago

Hi @akihikodaki

Thank you so much for the support, installing protobuf was the missing part to make it work.

Cheers!

Hi @alabeduarte I have same issue on installing cld3 -v 3.2.2 and protobuf is installed but same error is displayed.

Building native extensions. This could take a while...
ERROR:  Error installing cld3:
    ERROR: Failed to build gem native extension.

    current directory: /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/cld3-3.2.2/ext/cld3
/MYUSERPATH/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20180920-1677-qgse0h.rb extconf.rb
Failed to locate protobuf

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/cld3-3.2.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/cld3-3.2.2 for inspection.
Results logged to /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/cld3-3.2.2/gem_make.out

and here is the /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/cld3-3.2.2/mkmf.log

"pkg-config --exists protobuf"
| pkg-config --libs protobuf
=> "-L/usr/local/Cellar/protobuf/3.6.1/lib -lprotobuf -pthread\n"
"clang -o conftest -I/MYUSERPATH/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/MYUSERPATH/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/MYUSERPATH/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/MYUSERPATH/.rbenv/versions/2.5.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/MYUSERPATH/.rbenv/versions/2.5.1/lib -L. -L/MYUSERPATH/.rbenv/versions/2.5.1/lib  -fstack-protector -L/usr/local/lib     -lruby.2.5.1-static -framework Foundation  -lpthread -lgmp -ldl -lobjc "
ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"clang -o conftest -I/MYUSERPATH/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/MYUSERPATH/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/MYUSERPATH/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/MYUSERPATH/.rbenv/versions/2.5.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/MYUSERPATH/.rbenv/versions/2.5.1/lib -L. -L/MYUSERPATH/.rbenv/versions/2.5.1/lib  -fstack-protector -L/usr/local/lib     -lruby.2.5.1-static -framework Foundation -L/usr/local/Cellar/protobuf/3.6.1/lib -lprotobuf -pthread -lpthread -lgmp -ldl -lobjc "
ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

package configuration for protobuf is not found
akihikodaki commented 6 years ago

@mdf092 Having a look at your mkmf.log, I suspect your toolchain is corrupted. I'm not familiar with macOS and LLVM/clang, but as a general advice, I suggest to do:

Open another issue if you still have the same errors and you need help OR you believe this is cld3-ruby's bug since your problem looks very different from this issue.

inspire22 commented 3 years ago

In case anyone runs into this with ubuntu, the command to install protobuf is:

  apt-get install libprotobuf-dev protobuf-compiler
IvanTakarlikov-st commented 1 year ago

If anyone stuck with that on CentOS (or Amazon Linux 2) you can install required packages with:

yum install protobuf-devel protobuf-compiler