I've tried running
sudo apt-get install libsndfile
> E: Unable to locate package libsndfile
So then I try
sudo apt-get install libsndfile1
It installs, but where, how?
find /usr/ -name libsndfile*
> /usr/lib/x86_64-linux-gnu/libsndfile.so.1
> /usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.25
At the end of the day my goal is to get the lib to work for ruby, with either:
gem install sndfile
gem install ruby-audio
When I try installing ruby-audio, I get:
extconf.rb:21:in `<main>': Can't find libsndfile (http://www.mega-nerd.com/libsndfile/) (RuntimeError)
So for some reason the library doesn't install properly.
When you want to compile something against a library you'll need not only the library itself, which is usually one or more .so type files, but the header files that describe how the library works. These are often omitted unless you install the -dev version of the package:
apt-get install libsndfile-dev
This should give the Ruby extconf.rb enough information to compile and link against that library.
Related
I installed "eclipse" and want to run "fxruby" on fedora "linux", but it does not work it.
The error says :
cannot load such file -- fox16 (LoadError)
I installed this file with command
gem install fxruby
but fxruby not exist in gem list.
How can i fix it?
The warning about the path you can safely ignore (at least for now). What the error is telling you is that you do not have the FOX development headers and libraries installed, so it couldn't build the fxruby gem. So you must install the fox development package - it may be named something like "fox16" or "fox16-devel", or something else depending on what version of Linux you're running. (If all else fails, you can build it yourself).
After that, compiling fxruby (using gem install fxruby) should work.
If you do want to build FOX yourself, here are (approximately) the steps:
1) Go to the FOX website http://www.fox-toolkit.org/ , and download the latest 1.6 (stable) version (at the moment, fox-1.6.57.tar.gz).
2) I would create a directory ~/src, then cd ~/src, and unpack the downloaded package, e.g., tar xvf ~/Downloads/fox-1.6.57.tar.gz (adjust the path according to wherever you have actually downloaded the package).
2) You should now have a subdirectory fox-1.6.57 (i.e., ~/src/fox-1.6.57/). Cd to it, and read top-level documentation in README and INSTALL.
3) Run the configure script, ./configure or ./configure --prefix=$HOME.
The difference between these invocations is that if you run a plain ./configure, the software will be installed under the default location /usr/local (this will require root access when installed), whereas the invocation ./configure --prefix=$HOME will result in the software being installed under $HOME. The latter will not require root access to install and probably is better if you're just installing the software for your own use.
4) I you are installing under your own home directory, create appropriate subdirectories: cd ~; mkdir bin include lib'. (The installation may take care of this, but it doesn't hurt to pre-create the directories.)
5) Now run make. That should compile and build the FOX libraries under the local directory (~/src/fox-1.6.57/)
6) Run make install. That will install the libraries under either the default location of /usr/local or your home directory ~ (depending on your configure option)
7) A this point, you should have the FOX libraries and headers installed. Now try gem install fxruby. (If you're going for a local install, probably gem install fxruby --user-install.)
solved for fedora
i installed all of them :
ruby-devel.x86_64
fox-devel.x86_64
sudo dnf install redhat-rpm-config
yum groupinstall 'Development Tools'
yum group info 'Development Tools' yum -y install gcc ruby-devel
rubygems compass
gcc compt gcc-c++-x86_64-linux-gnu.x86_64
gcc-c++
[
gcc-c++-8.2.1-4.fc28.x86_64 C++ support for GCC
libstdc++-devel-8.2.1-4.fc28.x86_64 Header files and libraries for C++ development
]
sudo dnf install libpng12-devel.x86_64
sudo dnf install libb2-devel.x86_64
sudo dnf install libX11-devel
sudo dnf install libXcursor-devel.x86_64
sudo dnf install libXext-devel.x86_64 libXrandr-devel.x86_64
gem install fxruby
I tried to install rmagick using these commands, but it doesn't work.
sudo apt-get install imagemagick
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
sudo gem install rmagick
It ended up with the following error.
Building native extensions.
This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick /usr/bin/ruby2.3
-r ./siteconf20170603-20826-3to4j3.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/rmagick-2.16.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/rmagick-2.16.0/gem_make.out
You need to install also the ruby-dev package. That is why the ruby.h is not found when compiling a native extension.
Use the following command to install it.
sudo apt-get install ruby-dev
Basing on the package description, that will install the ruby2.3-dev package. That was the package it installed on my Ubuntu 16.04.
Package: ruby-dev
State: not installed
Multi-Arch: same
Version: 2:2.3.0+1bbox1~xenial1
Priority: optional
Section: devel
Maintainer: Antonio Terceiro
Architecture: amd64
Uncompressed Size: 20.5 k
Depends: ruby2.3-dev
Provided by: ruby1.8-dev (1:1.8.7.375-1bbox1~xenial2)
Description: Header files for compiling extension modules for Ruby (default version) Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in perl). It is simple, straight-forward, and extensible. This package contains the header files and the mkmf library, necessary to make extension library for Ruby. It is also required to build many gems. This package is a dependency package, which depends on Debian's default Ruby version (currently v2.3).
I then installed Ruby 2.4, so now that package doesn't result installed on my computer.
I installed Ruby v2.1.4 from source. I installed all necessary libaries using:
yum install gcc g++ make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel
All succeeded.
Now when I want to install a gem with:
gem install bundler-1.7.4.gem
I get:
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
I am sure that zlib is installed:
locate zlib
results in a long list of
/lib/modules/2.6.32-431.el6.x86_64/kernel/crypto/zlib.ko
/lib/modules/2.6.32-431.el6.x86_64/kernel/lib/zlib_deflate
/lib/modules/2.6.32-431.el6.x86_64/kernel/lib/zlib_deflate/zlib_deflate.ko
/lib64/rsyslog/lmzlibw.so
/usr/include/zlib.h
/usr/lib64/pkgconfig/zlib.pc
/usr/lib64/python2.6/encodings/zlib_codec.py
/usr/lib64/python2.6/encodings/zlib_codec.pyc
/usr/lib64/python2.6/encodings/zlib_codec.pyo
/usr/lib64/python2.6/lib-dynload/zlibmodule.so
/usr/local/share/doc/ruby/capi/html/db/d74/zlib_8c.html
/usr/local/share/doc/ruby/capi/html/db/d74/zlib_8c_source.html
/usr/local/share/ri/2.1.0/system/Zlib/zlib_version-c.ri
/usr/share/doc/zlib-1.2.3
/usr/share/doc/zlib-devel-1.2.3
/usr/share/doc/zlib-1.2.3/ChangeLog
/usr/share/doc/zlib-1.2.3/FAQ
/usr/share/doc/zlib-1.2.3/README
/usr/share/doc/zlib-devel-1.2.3/README
/usr/share/doc/zlib-devel-1.2.3/algorithm.txt
/usr/share/doc/zlib-devel-1.2.3/example.c
/usr/share/doc/zlib-devel-1.2.3/minigzip.c
/usr/share/man/man3/zlib.3.gz
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/zlib
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/crypto/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/jffs2/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/ubifs/fs/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/zlib/deflate.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/zlib/inflate.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_deflate
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_inflate
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_deflate/Makefile
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_inflate/Makefile
Did I miss something?
I have found the solution at this blog. I am unable to use rvm because server have no internet connection even through proxy.
While installing ruby from sources doing the following solved the issue:
Remove the installed Ruby with make clean
Install libssl-dev with your OS's package manager of choice. E.g. apt-get install libssl-dev
Install zlib1g-dev with your OS's package manager of choice. E.g. apt-get install zlib1g-dev
Config make file to include openssl by go to ext/openssl and run ruby extconf.rb
Config make file to include zlib by go to ext/zlib and run ruby extconf.rb
Go back to ruby source code directory run make && make install
You should be able to successfully run gem install bundler
I'm installing the Ruby Nokogiri gem and finding the error below.
How to diagnose this and solve it?
# gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
...
/opt/ruby/1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.h... *** 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.
...
/opt/ruby/1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do':
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/ruby/1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
...
To diagnose and solve, here's what worked for me.
To find out what failed, go to your ruby gems directory.
For example:
$ cd <MY RUBY DIRECTORY>/lib/ruby/gems/2.0.0/gems
If you don't know your gem directory, try this:
$ echo $GEM_HOME
/opt/gems/2.0.0
$ cd /opt/gems/2.0.0/gems
What version of nokogiri am I installing?
$ ls -ladg nokogiri-*
nokogiri-1.5.5
Go to the installer directory:
$ cd nokogiri-1.5.5/ext/nokogiri
Try installing manually:
$ ruby extconf.rb
Result:
checking for libxml/parser.h... *** extconf.rb failed ***
...
I'm using Ubuntu so I search for any similar packages:
$ aptitude search libxml
Results:
p libxml2 - GNOME XML library
p libxml2-dev - Development files for the GNOME XML library
...
I believe that libxml2 will work fine.
$ apt-get install libxml2
Ruby native gems often need the *-dev packages for headers so install them:
$ apt-get install libxml2-dev
Now do I have the parser file?
$ find / | grep libxml/parser.h
Yes, the result shows the parser:
/usr/include/libxml2/libxml/parser.h
Now try installing again, this time providing the libxml2 path:
$ gem install nokogiri -- --with-xml2-dir=/usr/include/libxml2
It still fails, so read the mkmf error log:
$ more mkmf.log
The error log shows what failed and has these lines that look promising:
package configuration for libxslt is not found
Is there a package for it?
$ aptitude search libxslt
Results:
v libxslt-dev
i libxslt-ruby
...
Install the dev package:
$ apt-get install libxslt-dev
Now try installing again, and also put xslt on the path:
$ gem install nokogiri -- \
--with-xml2-dir=/usr/include/libxml2 \
--with-xslt-dir=/usr/include/libxslt
Success!
Installing Nokogiri Website
'Installing Nokogiri' is a website dedicated to installing Nokogiri on the major platforms - Here is an excerpt about Installing Nokogiri on Ubuntu:
Because Nokogiri needs to be compiled and dynamically linked against
both libxml2 and libxslt, it has gained a reputation for being
complicated to install.
As of Nokogiri 1.6, libxml2 and libxslt source code is bundled with
Nokogiri, and compiled at gem-install-time. The instructions in this
document should work for all versions 1.6.4 and later.
Ubuntu / Debian
Installation should Just Work™ on Ubuntu and Debian using Nokogiri’s
vendored libxml2 and libxslt:
gem install nokogiri
[...]
Using Your System Libraries
If, instead of Nokogiri’s vendored libraries, you’d like to use your
system’s libxml2, libxslt and related libraries, please first
understand that you may be asking Nokogiri to work with an unsupported
version of libxml2.
sudo apt-get install pkg-config
gem install nokogiri -- --use-system-libraries
FYI - I am using Nokogiri 1.6.6.2 and it didn't 'just work'. I got it going with the --use-system-libraries.
Mac OS X
The website's advice also covers OS X - this worked for me:
gem update --system
xcode-select --install
gem install nokogiri
Conclusion
If you have a Nokogiri problem on any platform you should check out the website.
On CentOS here is what I needed to do:
gem update --system
yum install libxml2-devel libxslt-devel ruby-devel
gem install nokogiri -- --use-system-libraries
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
You are probably missing zlib headers which are required for -lz flag in order to compile the sources correctly. Install on Linux by:
sudo apt-get install libz-dev
For missing libiconv, try installing libiconv-hook-dev package which has header files of libiconv-hook, e.g.
sudo apt-get install libiconv-hook1 libiconv-hook-dev
On OS X, try installing development tools via: xcode-select --install.
If there is still problem, check mkmf.log file for more specific details about your error.
On Ubuntu, try the following dependency fix combo:
sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev
The 'could not create Makefile' error you're seeing could also be because you haven't agreed to the Xcode license (you have to agree to it after each time you update Xcode). Running sudo xcodebuild -license accept should eliminate this error for you and allow you to then run gem install nokogiri successfully.
The Ruby on Rails website recommends installing Ruby from source under Linux.
I encountered a number of C library problems building ruby from source on a clean install of Ubuntu 9.
All the instructions I found on the net about installing ruby on Ubuntu have involved using the prepackaged (.deb-based) ruby. Clearly this isn't what the rails people recommend.
When I did a clean source build of ruby I found Rubygems failed to install because the zlib extension didn't work.
Two problems occur:
1) The zlib extension isn't built.
Solution:
i) ensure zlib is uncommented in the Setup file within the extn directory of the ruby source, and
ii) ensure these zlib ubuntu packages are installed:
aptitude install zlib1g
aptitude install zlib1g-dbg
aptitude install zlib1g-dev
aptitude install zlibc
2) After fixing Problem 1 above (and doing a clean rebuild of ruby), zlib still doesn't work because the extension fails to load.
You can see that the module fails to load by running this and getting the output "false":
puts require 'zlib'
I observed this happens to any number of other C extensions in the extn directory, so it appears to be a more general problem with these extensions than just something zlib-specific.
To summarize:
My build of ruby finds the ruby-specific C zlib extension but it fails to load the zlib module.
This behaviour appears to happen to other extensions in /extn.
Is there a way I can find out why a module fails to load? some kind of trace/verbose mode?
Here is what I did to install ruby, gems and rails on Ubuntu 11.04
Install ruby from sources
Install RubyGems from sources
Install zlib:
sudo apt-get install zlib1g-dev
cd your-ruby-sources/ext/zlib
ruby extconf.rb
make
sudo make install
Install readline:
sudo apt-get install libreadline5-dev
cd your-ruby-sources/ext/readline
ruby extconf.rb
make
sudo make install
Install openssl:
sudo apt-get install libssl-dev
cd your-ruby-sources/ext/openssl
ruby extconf.rb
make
sudo make install
I don't see what your problem is. You say that require 'zlib' returns false. But that means that it did work! If there were an error, you would get a LoadError exception.
Did you install libzlib-ruby? Here's my typical Ubuntu initialization before installing Rubygems:
$ apt-get update
$ apt-get dist-upgrade
$ apt-get install build-essential -y
$ apt-get install rsync -y
$ apt-get install ruby ri rdoc irb ri1.8 ruby1.8-dev libzlib-ruby zlib1g libopenssl-ruby -y