Install matplotlib in CentOS using yum - gcc

I'm looking to install matplotlib on CentOS using :
yum install python-matplotlib.x86_64
It works but the problem is that it is an old version (matplotlib 0.99.1.1) and I need the last version : [1.3.1].
So I've downloaded the source and trying with : python setup.py install
But I get this error ...
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.3.1]
python: yes [2.6.6 (r266:84292, Jan 22 2014, 09:42:36) [GCC
4.4.7 20120313 (Red Hat 4.4.7-4)]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.8.1]
dateutil: yes [using dateutil version 1.4.1]
tornado: yes [using tornado version 3.2.2]
pyparsing: yes [using pyparsing version 2.0.2]
pycxx: yes [Couldn't import. Using local copy.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: yes [version 9.22.3]
png: yes [version 1.2.49]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: yes [nose 0.11.1 or later is required to run the
matplotlib test suite]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt4agg: no [PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires pygobject to be installed.]
Xlib: extension "RANDR" missing on display "localhost:22.0".
gtkagg: no [The C/C++ header for gtk (gtk/gtk.h) could not
be found. You may need to install the development
package.]
tkagg: yes [installing, version 73770]
wxagg: no [requires wxPython]
gtk: no [The C/C++ header for gtk (gtk/gtk.h) could not
be found. You may need to install the development
package.]
agg: yes [installing]
cairo: yes [installing, version 1.8.6]
windowing: no [Microsoft Windows only]
OPTIONAL LATEX DEPENDENCIES
dvipng: yes [version 1.11]
ghostscript: yes [version 8.70]
latex: yes [version 3.141592]
pdftops: no
running install
running bdist_egg
running egg_info
writing requirements to lib/matplotlib.egg-info/requires.txt
writing lib/matplotlib.egg-info/PKG-INFO
writing namespace_packages to lib/matplotlib.egg-info/namespace_packages.txt
writing top-level names to lib/matplotlib.egg-info/top_level.txt
writing dependency_links to lib/matplotlib.egg-info/dependency_links.txt
reading manifest file 'lib/matplotlib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'lib/matplotlib.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-2.6/matplotlib/mpl-data
running build_ext
building 'matplotlib._png' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib__png_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/lib64/python2.6/site-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/include/libpng12 -I/usr/include/python2.6 -c src/_png.cpp -o build/temp.linux-x86_64-2.6/src/_png.o
In file included from /usr/lib64/python2.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1798,
from /usr/lib64/python2.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
from /usr/lib64/python2.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from src/_png.cpp:28:
/usr/lib64/python2.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
src/_png.cpp:243:48: error: macro "npy_PyFile_DupClose" requires 3 arguments, but only 2 given
src/_png.cpp:264:44: error: macro "npy_PyFile_DupClose" requires 3 arguments, but only 2 given
src/_png.cpp:577:44: error: macro "npy_PyFile_DupClose" requires 3 arguments, but only 2 given
In file included from src/file_compat.h:4,
from src/_png.cpp:31:
/usr/lib64/python2.6/site-packages/numpy/core/include/numpy/npy_3kcompat.h: In function ‘PyObject* npy_PyFile_OpenFile(PyObject*, const char*)’:
/usr/lib64/python2.6/site-packages/numpy/core/include/numpy/npy_3kcompat.h:348: warning: deprecated conversion from string constant to ‘char*’
/usr/lib64/python2.6/site-packages/numpy/core/include/numpy/npy_3kcompat.h: In function ‘int npy_PyFile_CloseFile(PyObject*)’:
/usr/lib64/python2.6/site-packages/numpy/core/include/numpy/npy_3kcompat.h:356: warning: deprecated conversion from string constant to ‘char*’
src/_png.cpp: In member function ‘Py::Object _png_module::write_png(const Py::Tuple&)’:
src/_png.cpp:243: error: ‘npy_PyFile_DupClose’ was not declared in this scope
src/_png.cpp:264: error: ‘npy_PyFile_DupClose’ was not declared in this scope
src/_png.cpp: In member function ‘PyObject* _png_module::_read_png(const Py::Object&, bool, int)’:
src/_png.cpp:329: warning: deprecated conversion from string constant to ‘char*’
src/_png.cpp:577: error: ‘npy_PyFile_DupClose’ was not declared in this scope
error: command 'gcc' failed with exit status 1
Any helps ?
Thanks

This has been fixed in version 1.4.0 (see patch here). I have successfully compiled version 1.4.0 on CentOS 6.5 after patching setupext.py to lower the required freetype version (as suggested in the installation notes).

Related

Failed to test on bazel due to issues with c++ version required

BUILD.bazel:69:11: Compiling absl/numeric/int128.cc failed: (Exit 1):
gcc failed: error executing command
/opt/rh/devtoolset-3/root/usr/bin/gcc -U_FORTIFY_SOURCE
-fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ...
gcc: error: unrecognized command line option '-std=c++17'
$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Why is the old version of GCC being used when I have the newer GCC (v8) already installed in my centOS?
Initially I upgraded the gcc version from 4.8 to 8 but it is still not working

Installing a program PHOEBE 2

Here are the instructions: Download & Install PHOEBE 2.1.6
First attempt:
pip install numpy phoebe
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (1.11.0) Collecting phoebe Using cached https://files.pythonhosted.org/packages/86/18/65d72fe5cf21c9e678d81408566a535026c782327869b7dcbffecd347de5/phoebe-2.1.6.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-ty7hrmts/phoebe/setup.py", line 6 print "Numpy is needed for running and building of PHOEBE" ^ SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-ty7hrmts/phoebe/ You are using pip version 19.0.3, however version 19.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
Second attempt from https://github.com/phoebe-project/phoebe2
I have problem with
python setup.py build
python setup.py build /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src build_src building extension "libphoebe" sources building extension "phoebe.algorithms.ceclipse" sources build_src: building npy-pkg config files running build_py running build_ext customize UnixCCompiler customize UnixCCompiler using build_check customize UnixCCompiler customize UnixCCompiler using build_check OS: Linux OS version: 4.10.0-38-generic sh: 1: c++: not found Compiler: c++ Compiler version: C compiler: i686-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC
compile options: '-I/usr/include/python2.7 -c' i686-linux-gnu-gcc: /tmp/6KUBK1XJLW_compiler_check.c i686-linux-gnu-gcc -pthread /tmp/6KUBK1XJLW_compiler_check.o -o /tmp/6KUBK1XJLW_compiler_check.exe Ready to compile with gcc 5.4.0 . OS: Linux OS version: 4.10.0-38-generic Compiler: i686-linux-gnu-gcc Compiler version: i686-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609 Ready to compile with gcc 5.4.0. extra_args=['-std=c++11'] extra_args=[] building 'libphoebe' extension compiling C++ sources C compiler: c++ -pthread -DNDEBUG -g -fwrapv -O2 -Wall -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC
compile options: '-I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c' extra options: '-std=c++11' c++: ./phoebe/lib/libphoebe.cpp sh: 1: c++: not found sh: 1: c++: not found error: Command "c++ -pthread -DNDEBUG -g -fwrapv -O2 -Wall -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c ./phoebe/lib/libphoebe.cpp -o build/temp.linux-i686-2.7/phoebe/lib/libphoebe.o -std=c++11" failed with exit status 127
c++: not found
I tried it install by
sudo apt install c++
but it was not successful
Third attempt, I tried:
pip2 install --user phoebe
and I get an error about c++ again
What I do wrong please? Thank you
The error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/betka/.local/lib/python2.7/site-packages/phoebe/__init__.py", line 276, in <module>
from .dependencies.unitsiau2015 import u,c
File "/home/betka/.local/lib/python2.7/site-packages/phoebe/dependencies/__init__.py", line 1, in <module>
from . import autofig
File "/home/betka/.local/lib/python2.7/site-packages/phoebe/dependencies/autofig/__init__.py", line 17, in <module>
from .call import Plot, Mesh
File "/home/betka/.local/lib/python2.7/site-packages/phoebe/dependencies/autofig/call.py", line 2, in <module>
import astropy.units as u
File "/home/betka/.local/lib/python2.7/site-packages/astropy/__init__.py", line 116, in <module>
_check_numpy()
File "/home/betka/.local/lib/python2.7/site-packages/astropy/__init__.py", line 104, in _check_numpy
from .utils import minversion
ImportError: No module named utils
First, try to install build tool How to install G++ the C++ compiler on Ubuntu
sudo apt install g++
sudo apt install build-essential
Then try again.

Rstudio unable to install package devtools: gcc error

I want to install package devtools. But after successful downloading of all dependencies, it gives error while installing of the form:
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c rawmatch.c -o rawmatch.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'rawmatch.o' failed
make: *** [rawmatch.o] Error 1
ERROR: compilation failed for package ‘mime’
* removing ‘/usr/local/lib/R/site-library/mime’
I have checked gcc. I am able to run a sample c program file from terminal.
It seems you'll need to use a more recent gcc version, 4.9 at least.
Both unrecognized options, -fstack-protector-strong and -Wdate-time, were introduced in gcc 4.9 (release notes).

HDF5 library and header mismatch error

I am using Anaconda on Ubuntu x64. When I run a simple python program, I get this error message and a [python] kernel dump. I have seen other questions with similar problems, but all the answers I see don't resolve my issue. I have tried removing and reinstalling h5py with both pip and conda, but I get the same error:
idf#DellInsp:~/Documents/Projects/python3$ python3 testtables.py
With this code inside testtables.py
import tables
tables.test()
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PyTables version: 3.2.2
HDF5 version: 1.8.11
NumPy version: 1.10.1
Numexpr version: 2.4.4 (not using Intel's VML/MKL)
Zlib version: 1.2.8 (in Python interpreter)
Blosc version: 1.4.4 (2015-05-05)
Blosc compressors: blosclz (1.0.2.1), lz4 (1.2.0), lz4hc (1.2.0), snappy (1.1.1), zlib (1.2.8)
Cython version: 0.23.4
Python version: 3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, 21:57:25)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
Platform: Linux-3.19.0-39-lowlatency-x86_64-with-debian-jessie-sid
Byte-ordering: little
Detected cores: 4
Default encoding: utf-8
Default FS encoding: utf-8
Default locale: (en_US, UTF-8)
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Performing only a light (yet comprehensive) subset of the test suite.
If you want a more complete test, try passing the --heavy flag to this script
(or set the 'heavy' parameter in case you are using tables.test() call).
The whole suite will take more than 4 hours to complete on a relatively
modern CPU and around 512 MB of main memory.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/home/idf/anaconda3/lib/python3.5/site-packages/tables/filters.py:292: FiltersWarning: compression library ``bzip2`` is not available; using ``zlib`` instead
% (complib, default_complib), FiltersWarning)
/home/idf/anaconda3/lib/python3.5/site-packages/tables/filters.py:292: FiltersWarning: compression library ``lzo`` is not available; using ``zlib`` instead
% (complib, default_complib), FiltersWarning)
/home/idf/anaconda3/lib/python3.5/site-packages/tables/atom.py:570: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
for arg in inspect.getargspec(self.__init__)[0]
Warning! ***HDF5 library version mismatched error***
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.8.11, library is 1.8.15
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.8.15-patch1
Configured on: Wed Oct 14 16:46:37 CDT 2015
Configured by: ilan#centos5x64.corp.continuum.io
Configure mode: production
Host system: x86_64-unknown-linux-gnu
Uname information: Linux centos5x64.corp.continuum.io 2.6.18-400.1.1.el5 #1 SMP Thu Dec 18 00:59:53 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
Byte sex: little-endian
Libraries: shared
Installation point: /home/ilan/minonda/envs/_build
Compiling Options:
------------------
Compilation Mode: production
C Compiler: /usr/bin/gcc ( gcc (GCC) 4.1.2 20080704 )
CFLAGS:
H5_CFLAGS: -std=c99 -pedantic -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wfloat-equal -Wmissing-format-attribute -Wmissing-noreturn -Wpacked -Wdisabled-optimization -Wformat=2 -Wunreachable-code -Wendif-labels -Wdeclaration-after-statement -Wold-style-definition -Winvalid-pch -Wvariadic-macros -Wnonnull -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros -Wunsafe-loop-optimizations -Wc++-compat -Wvolatile-register-var -O3 -fomit-frame-pointer -finline-functions
AM_CFLAGS:
CPPFLAGS:
H5_CPPFLAGS: -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L -DNDEBUG -UH5_DEBUG_API
AM_CPPFLAGS: -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE
Shared C Library: yes
Static C Library: no
Statically Linked Executables: no
LDFLAGS:
H5_LDFLAGS:
AM_LDFLAGS:
Extra libraries: -lrt -lz -ldl -lm
Archiver: ar
Ranlib: ranlib
Debugged Packages:
API Tracing: no
Languages:
----------
Fortran: no
C++: yes
C++ Compiler: /usr/bin/g++ ( g++ (GCC) 4.1.2 20080704 )
C++ Flags:
H5 C++ Flags:
AM C++ Flags:
Shared C++ Library: yes
Static C++ Library: no
Features:
---------
Parallel HDF5: no
High Level library: yes
Threadsafety: no
Default API Mapping: v18
With Deprecated Public Symbols: yes
I/O filters (external): deflate(zlib)
MPE: no
Direct VFD: no
dmalloc: no
Clear file buffers before write: yes
Using memory checker: no
Function Stack Tracing: no
Strict File Format Checks: no
Optimization Instrumentation: no
Bye...
Aborted (core dumped)
idf#DellInsp:~/Documents/Projects/python3$
After trying several options, an uninstall followed by re-install solved the problem:
pip uninstall h5py
pip install h5py
I removed then installed version the latest version of Anaconda. This resolved this issues.
I had this same error as well. I was trying to use the default debian package libhdf5-dev. I would encourage debi / pip to update. You have to find the proper version here: https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.15-patch1/src/ and build it from source. once you have it
tar -xvf hdf5-1.8.15-patch1
cd hdf5-1.8.15-patch1
./configure --prefix=/usr/local/hdf5
make
make check
make install
make check-install
pip install h5py
Please note, this can be done with other versions of hdf5 as well. This is just the one that corresponds to the version from the pip repositories.

compiler error while installing rubygem 'mysql2' in Ruby 1.9.2 over CentOS 64-bit

a CentOS 64-bit Server with Ruby 1.8.7 & 1.9.2
{{no RVM, need it without RVM...
currently all Ruby1.9.2 binaries are ruby19 and similarly accessible,
so no mapping of gem-path or anything of that sort is there}}
is giving error while installing gem 'mysql2' ...
I have all dependencies installed and all are 64-bit versions ...
All error are of kind {./client.h:13:
error: redefinition of typedef
‘rb_unblock_function_t’}
Could {#warning rubysig.h is obsolete}
be a reason for this?
Console Capture:
#gem19 install mysql2 -v 0.2.7 -- --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby19 extconf.rb --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql
checking for rb_thread_blocking_region()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -Wall -fno-strict-aliasing -fPIC -Wall -funroll-loops -o result.o -c result.c
In file included from ./client.h:11,
from ./mysql2_ext.h:39,
from result.c:1:
/usr/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
In file included from ./mysql2_ext.h:39,
from result.c:1:
./client.h:13: error: redefinition of typedef ‘rb_unblock_function_t’
/usr/include/ruby-1.9.1/ruby/intern.h:754: error: previous declaration of ‘rb_unblock_function_t’ was here
./client.h:14: error: redefinition of typedef ‘rb_blocking_function_t’
/usr/include/ruby-1.9.1/ruby/intern.h:755: error: previous declaration of ‘rb_blocking_function_t’ was here
./client.h:20: error: static declaration of ‘rb_thread_blocking_region’ follows non-static declaration
/usr/include/ruby-1.9.1/ruby/intern.h:759: error: previous declaration of ‘rb_thread_blocking_region’ was here
./client.h: In function ‘rb_thread_blocking_region’:
./client.h:23: warning: ‘rb_thread_blocking_region_begin’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:31)
./client.h:25: warning: ‘rb_thread_blocking_region_end’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:32)
In file included from ./mysql2_ext.h:39,
from result.c:1:
./client.h:41:7: warning: no newline at end of file
make: *** [result.o] Error 1
This is caused by a patch they introduced on the gem in order for it to run in Ruby 1.8 but it is not needed on Ruby 1.9.
To deactivated this "fix" and be able to install the gem you can define a flag for the compiler:
gem install mysql2 -- --with-cflags=\"-DHAVE_RB_THREAD_BLOCKING_REGION\"
The problem is in the extconf/mkmf section:
rb_thread_blocking_region()... no
But Ruby 1.9.2 defines rb_thread_blocking_region (unless you built Ruby
with some funky set of ifdef's and edits I'm not aware of).
Check your mkmf.log file. It should show you that Ruby failed
to compile/link the conftest.c file that tests for
rb_thread_blocking_region. The reason why is that libcrypt.a
has a dependency on libfreebl3, but the library isn't getting
referenced on the link line.
I fixed the problem by editing /usr/local/lib/ruby/1.9.1/i686-linux/rbconfig.rb like so:
- CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lm "
+ CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lfreebl3 -lm "
I was able to build the mysql2 gem after. No need to install rvm, etc.
What I did to fix it was to re-install Ruby via RVM. There no more errors after that.
Alternatively, remove the block in client.h that is trying to emulate rb_thread_blocking_region for Ruby 1.8 and you'll be good to go.

Resources