1

I am trying to build some code, but find that I need to alter the configure.ac file first, as it is not searching in the correct place for the ruby headers. Today is the first day I have ever even looked at config.ac files, so there were bound to be issues when digging around in them and changing them! But yes, I am a complete newbie to these kinds of things, so apologies if this is a silly question.

On my system the ruby.h file is located at /usr/include/ruby/ruby.h, and there is actually a similarly named file at /usr/include/ruby.h. I'll admit that I don't know which one is correct, but either way, my configure script cannot find it.

This is the part of my configure.ac file that SHOULD be finding the right headers:

CPPFLAGS="$CPPFLAGS -I/usr/include/ruby"
AC_MSG_CHECKING([CPPFLAGS are $CPPFLAGS])
AC_CHECK_HEADER([ruby.h],
                [AC_DEFINE(HAVE_RUBY_H, 1, [has ruby.h -- ruby-dev is installed] )],
                [AC_MSG_ERROR([Sorry, you need ruby-dev (headers) installed])])
CPPFLAGS=$SAVE_CPPFLAGS

But this is the output I am getting:

checking ruby.h usability... no
checking ruby.h presence... no
checking for ruby.h... no
configure: error: Sorry, you need ruby-dev (headers) installed

In the config.log file, the following message is given:

configure:13689: checking ruby.h usability
configure:13689: gcc -c   -I/usr/include/ruby/ conftest.c >&5
In file included from conftest.c:69:0:
/usr/include/ruby/ruby.h:24:25: fatal error: ruby/config.h: No such file or directory

I don't understand what the config.h file it is looking for is exactly.

Also, I found a similar problem here, but I tried the proposed fixes (namely specifying the path within the AC_CHECK_HEADER call), but nothing worked. I also saw this question here, which makes me think that my problem MIGHT be a permissions issue, but I still don't know the purpose of the config.h file that the log talks about. It is nowhere to be found.

Any ideas?

Community
  • 1
  • 1
N-C
  • 155
  • 1
  • 9
  • You absolutely do not need or want to alter `configure.ac`. You just need to properly specify `CPPFLAGS` when you run the configure script. – William Pursell Mar 11 '13 at 22:24
  • `config.h` is a file that should never be installed. If you are locating a `ruby.h` that includes `config.h`, then you are finding the wrong `ruby.h`. What is the value of `CPPFLAGS` when you run the `configure` script? – William Pursell Mar 11 '13 at 22:28
  • @WilliamPursell Oh, that is good to know that I don't have to modify this file. Also, the ruby.h file I am linking to DOES include "ruby/config.h". I edited my original post to include the error I am getting from the config script. CPPFLAGS is set to `-I/usr/include/ruby/` when I run the script, due to my modification. Originally the CPPFLAGS was set to `/usr/lib64/` – N-C Mar 11 '13 at 22:46
  • Sadly, ruby installs a `config.h` that looks like it came out of `autoheader`. – Jack Kelly Mar 12 '13 at 01:51

1 Answers1

0

The basic problem is that it looks like you have an incomplete installation of Ruby headers. The Autoconf probe is fine (except that you generally shouldn't change CPPFLAGS in configure.ac, since it's reserved for the user).

The real question here is what happened to your ruby/config.h file. This should be part of a normal Ruby development files installation.

It's worth noting that on Debian and Ubuntu, where some headers have been moved for multiarch (so that multiple architectures of a package can be installed at the same time), the ruby/config.h file, since it is architecture-dependent, has been moved to a subdirectory. On my system, for example:

windlord:/usr/include/ruby-1.9.1> ls -R
.:
i486-linux/  ruby/  ruby.h

./i486-linux:
ruby/

./i486-linux/ruby:
config.h

./ruby:
backward/  dl.h        io.h         re.h     st.h     version.h
defines.h  encoding.h  missing.h    regex.h  subst.h  vm.h
digest.h   intern.h    oniguruma.h  ruby.h   util.h

./ruby/backward:
classext.h  rubyio.h  rubysig.h  st.h  util.h

I would therefore expect the error message that you're getting if you're trying to use a compiler that isn't multiarch-aware and therefore doesn't know to search in the /usr/include/i486-linux directory, and you're using a multiarch installation of Ruby. Could that be the issue?

rra
  • 3,807
  • 18
  • 29