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

后端 未结 1 674
梦如初夏
梦如初夏 2021-02-10 06:04

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         


        
相关标签:
1条回答
  • 2021-02-10 06:49

    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?

    0 讨论(0)
提交回复
热议问题