On a CentOS 5.7 box, I\'m having trouble installing the newest version of the mysql2 gem; it\'s not finding errmsg.h:
/usr/bin/ruby extconf.rb
checking for rb_th
I believe I've found an answer.
It appears that have_header
looks at the system include path. If the relevant environment variables are not set, the default include paths are /usr/local/include
and /usr/include
.
If you want to set them manually, you would do something like:
export C_INCLUDE_PATH=/usr/include/mysql/
That's true even if you're compiling a C++ program, if the header file is a C file. If, on the other hand, your header file is C++, not C, you would do:
export CPLUS_INCLUDE_PATH=/usr/include/mysql
Of course, you found the work-around, which is to include dir_config('mysql')
in your extconf.rb
. That enables you to use the --with-mysql-include
option and supply the path manually.
Here's my source: http://www.network-theory.co.uk/docs/gccintro/gccintro_23.html
And here's a more general version of the same question (with answers): How to add a default include path for gcc in linux?