Where does Ruby's have_header method look for header files?

安稳与你 提交于 2019-12-03 08:23:26
Doctor Mohawk

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!