crubygcc

How to compile a simple source file with GCC in Linux


I am trying to compile a set of source files in C in Linux (Ubuntu). When I try to run the following command, I am getting an error telling "ruby.h" is not found.

gcc custom_ext.c

This was giving me the following error message.

custom_ext.h:10: fatal error: ruby.h: No such file or directory

So I downloaded the entire Ruby source code and put it in a dummy directory /home/braga/ruby_source/ruby_1_8_7. I know that I need to include this directory in the path so that GCC will be able to identify and pick up ruby.h, but I have no idea on how to do that. Please help!!!


Solution

  • Did you installed "ruby-dev" package?

    All you need is install packages from Ubuntu repositorie (using "apt-get", "aptitude", or any other package manager front-end). No need in downloading sources. Installing package will plcase all tour required headers and libraries in standard directories, so you will not have to deal with compiler keys.

    And only if you do not have required packages in repos (or it is so old), you'll have to download sourcecode tarballs and INSTALL it (accordingly included in tarball instructions, often in file INSTALL).