1

I am trying to get some code that I acquired from a repository to work on my system.

In one of the C files, it contains an absolute path to a header:

 #include "/home/user/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux/ruby/config.h"

Because this file and directory does not exist on my system, compiling the source code fails.

I assume if I change this to point at my personal location of config.h, it will succeed but then fail on others' systems.

Is there a way to point at some symbolic link that the system will then use the proper location for such a file? What is the best way to approach this situation?

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
Strobecast
  • 21
  • 2

1 Answers1

4

Change it to #include "ruby/config.h", and then add -I/home/user/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux/ (or whatever your location is) to your compiler options. This tells the preprocessor to add that directory to the list of directories to search when looking for #includes.

To solve the portability you can then change whatever generates the makefile to take this path as an option/argument, or you can just put it in a variable at the top of the makefile and ask people to change it:

RUBY_LOCATION = /home/user/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux/

CFLAGS = -Wall -I${RUBY_LOCATION}
Timothy Jones
  • 21,495
  • 6
  • 60
  • 90