You are not logged in.
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
/usr/include/ruby-2.6.0/ruby/ruby.h comes w/ the "ruby" package …
Offline
/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
Maybe add /usr/include/ruby-2.6.0/ to the include path…?
Offline
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@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
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
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
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
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@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline