Reputation: 33
I’m trying to run a block of Ruby code inside a C program.
I have the following code:
#include <ruby.h>
int main(int argc, char* argv[])
{
/* Construct the VM */
ruby_init();
/* Ruby goes here */
/* Destruct the VM */
return ruby_cleanup(0);
}
But when I try to run the program, I get the following error:
fatal error: ruby.h: No such file or directory
#include <ruby.h>
I read that it is needed to tell the compiler about the include paths for the required headers with the following code in Ubuntu:
pkg-config --cflags --libs ruby-2.5
gcc -I/usr/include/ruby-2.5.0 -I/usr/include/ruby-2.5.0/x86_64-linux -lruby
I have already done that, but the problem isn’t solved.
Here is the link: https://silverhammermba.github.io/emberb/embed/
Upvotes: 0
Views: 369
Reputation: 21
Follow the steps in How can I include a needed C library using GCC?.
I don't understand the difference between the two -l
, but try to follow the following structure. If I'm right, your command will be like:
gcc -I/usr/include/ruby-2.5.0 -L/usr/include/ruby-2.5.0/x86_64-linux -lruby
Where:
-I <searchpath to include files>
-L <searchpath to the lib file>
-l <thelibname>
I don't know if the library is the first or the second parameter, but you can check it.
Upvotes: 2