You are not logged in.

#1 2019-04-22 06:47:37

Sourav
Member
From: India
Registered: 2019-04-22
Posts: 19
Website

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

When I try to compile a C file named p.c with the following codes:

#include<stdio.h>
#include<ruby.h>
#include<ruby/io.h>

int main() {
}

----------

I get the error:

p.c:2:9: fatal error: ruby.h: No such file or directory
#include<ruby.h>
         ^~~~~~~~
compilation terminated.

----------

I have used Debian / Debian based and Fedora systems where I can install the ruby-dev package to solve this issue. However, since pacman doesn't have the ruby-dev package in any of  it's repository, I just wonder what can I do to fix this issue.

Last edited by Sourav (2019-04-22 06:49:10)

Offline

#2 2019-04-22 07:03:14

seth
Member
Registered: 2012-09-03
Posts: 11,946

Re: fatal error: ruby.h: No such file or directory

/usr/include/ruby-2.6.0/ruby/ruby.h comes w/ the "ruby" package …

Offline

#3 2019-04-22 07:11:21

Sourav
Member
From: India
Registered: 2019-04-22
Posts: 19
Website

Re: fatal error: ruby.h: No such file or directory

seth wrote:

/usr/include/ruby-2.6.0/ruby/ruby.h comes w/ the "ruby" package …

Ok, first things first, I have ruby, ruby-rdocs, ruby-doc packages, and also the base-devel group installed.

Now, in my code, if I include
    #include</usr/include/ruby-2.6.0/ruby/ruby.h>

I get another error:
/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: ruby/config.h: No such file or directory
#include "ruby/config.h"

Offline

#4 2019-04-22 07:15:43

seth
Member
Registered: 2012-09-03
Posts: 11,946

Re: fatal error: ruby.h: No such file or directory

Maybe add /usr/include/ruby-2.6.0/ to the include path…?

Offline

#5 2019-04-22 07:17:11

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 3,990

Re: fatal error: ruby.h: No such file or directory

Specify the include dir when you call CC. Even better, use meson.

Your original example compiles with

CC -I/usr/include/ruby-2.6.0/ -I/usr/include/ruby-2.6.0/x86_64-linux/ main.c

Also, please use code tags for code.

Last edited by Mr.Elendig (2019-04-22 07:22:25)


Evil #archlinux@freenode channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#6 2019-04-22 12:45:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 21,880
Website

Re: fatal error: ruby.h: No such file or directory

And/or learn to use pkgconf properly when you are compiling something - you'll also need ruby specific flags for linking.  This is precisely what pkgconf is for and why the ruby package comes with a .pc file.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2019-04-22 14:27:49

Sourav
Member
From: India
Registered: 2019-04-22
Posts: 19
Website

Re: fatal error: ruby.h: No such file or directory

Mr.Elendig wrote:

Specify the include dir when you call CC. Even better, use meson.

Your original example compiles with

CC -I/usr/include/ruby-2.6.0/ -I/usr/include/ruby-2.6.0/x86_64-linux/ main.c

Also, please use code tags for code.


Nice, it worked with cc.

Sorry for the late reply. But I also tested this on fedora. After installing ruby-devel, I just got it working with GCC.

----------

However, I am seeing that the config.h is really included under /usr/include/ruby-2.6.0/x86_64-linux/ruby/ directory. But on most systems we find this under /usr/include/ruby-2.6.0/ruby/ directory.

----------

But it worked with cc after including the path...

Offline

#8 2019-04-22 14:29:07

Sourav
Member
From: India
Registered: 2019-04-22
Posts: 19
Website

Re: fatal error: ruby.h: No such file or directory

Trilby wrote:

And/or learn to use pkgconf properly when you are compiling something - you'll also need ruby specific flags for linking.  This is precisely what pkgconf is for and why the ruby package comes with a .pc file.

I just got it with pacman. I also have RVM installed where I have other Ruby versions.
But it solved my issue if I specify the path in cc.

Offline

#9 2019-04-22 18:04:05

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 3,990

Re: fatal error: ruby.h: No such file or directory

Sourav wrote:
Mr.Elendig wrote:

Specify the include dir when you call CC. Even better, use meson.

Your original example compiles with

CC -I/usr/include/ruby-2.6.0/ -I/usr/include/ruby-2.6.0/x86_64-linux/ main.c

Also, please use code tags for code.


Nice, it worked with cc.

Sorry for the late reply. But I also tested this on fedora. After installing ruby-devel, I just got it working with GCC.

----------

However, I am seeing that the config.h is really included under /usr/include/ruby-2.6.0/x86_64-linux/ruby/ directory. But on most systems we find this under /usr/include/ruby-2.6.0/ruby/ directory.

----------

But it worked with cc after including the path...

CC is just a placeholder for the C compiler, usually gcc or clang, it is the include flags (-I) that does the "magic"


Evil #archlinux@freenode channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

Board footer

Powered by FluxBB