I received the below error when attempting to install the memprof gem on a CentOS Linux server. The errors pointed out below could occur when attempting to install other packages as well though. Below I display a summary of the error output, the entire error output, and information on what to install to resolve the error. I noticed that on one server where the memprof gem installed without issue the gelf.h file was in the /usr/include/ directory however are the server that produced the error gelf.h was not installed.
Errors:
checking for gelf_getshdr() in -lelf… no
checking for mach-o/dyld.h… no
The two above errors are what provided the information needed to locate the issue. Below is the complete output of the attempt to try and install the memprof gem.
Error Installing memprof gem:
- [root@dev ~]# gem install memprof
- Building native extensions. This could take a while...
- ERROR: Error installing memprof:
- ERROR: Failed to build gem native extension.
- /usr/local/bin/ruby extconf.rb install memprof
- checking for gelf_getshdr() in -lelf... no
- checking for mach-o/dyld.h... no
- *** 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=/usr/local/bin/ruby
- --with-elflib
- --without-elflib
- Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/memprof-0.1.2 for inspection.
- Results logged to /usr/local/lib/ruby/gems/1.8/gems/memprof-0.1.2/ext/gem_make.out
To resolve the error simply install the elfutils-libelf-devel package. This can be completed on CentOS using the yum package manager by using the below syntax. On other distributions just install the elfutils-libelf-devel package using whatever package manager you prefer or download the RPM file and install it that way.
Install elfutils-libelf-devel Using Yum Package Manager:
- yum install elfutils-libelf-devel
This should resolve the “gelf_getshdr” error. In this specific case you should not be able to install the memprof gem as shown below.
Install memprof gem:
- [root@dev ~]# gem install memprof
- Building native extensions. This could take a while...
- Successfully installed memprof-0.1.2
- 1 gem installed
- Installing ri documentation for memprof-0.1.2...
- Installing RDoc documentation for memprof-0.1.2...
Now the memprof gem is installed without issue. You can now plug it into your code to assist with locating ruby memory leak issues.
Thanks! FYI for others on Ubuntu/Debian-ish systems, you need to do this:
$ sudo apt-get install libelfg0-dev
And then install memprof. HTH.
Hello John,
No problem. Glad it helped you out. Thanks for taking the time to provide installation syntax for Debian and Ubuntu! I am sure this will help someone else along the way.
Thanks.
alex