Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!!

like image 454
bragboy Avatar asked Dec 28 '22 03:12

bragboy


2 Answers

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).

like image 121
Vovanium Avatar answered Jan 05 '23 10:01

Vovanium


-I /home/braga/ruby_source/ruby_1_8_7. Chances are that ruby.h lives in some subdirectory of that though, so you'll have to find it, and use the path to that directory though.

like image 29
Jerry Coffin Avatar answered Jan 05 '23 10:01

Jerry Coffin