gisek
gisek

Reputation: 53

Statically link ruby libraries to c++ application

I recently asked a question concerning embedding ruby in a c++ application

Embedding ruby in c++, problem with ruby libraries

Now I encountered another problem related to this. I managed to compile and run this application, but i can't link ruby statically. This is what my console says:

####:~/Desktop/rubyParser$ g++ -o ruby_test ruby_test.c -I/usr/lib/ruby/1.8/x86_64-linux/ -static -lruby1.8
/usr/bin/ld: cannot find -lruby1.8

But if I open /usr/bin, there is a "ruby1.8" file (no extension). Probably i need another file.. I'm using Ubuntu and I'm NOT a Linux expert of course, so please be patient with me :)

How can I fix it?

Thanks in advance

Bye

Upvotes: 2

Views: 890

Answers (3)

Jason
Jason

Reputation: 32510

You may need to, if you've recently installed the Ruby libraries in question, go to the command-line and type in sudo ldconfig to refresh ld's configuration files with the latest versions of your libraries and their locations.

Edit: From the comments below, you'll only need to-do this step if you run into a run-time linking problem, which you haven't at this point. But it's at least something to keep in-mind as it has solved run-time linking problems for me in the past (i.e., helped me with GMP).

Upvotes: 0

ereOn
ereOn

Reputation: 55726

By specifying -lruby1.8 the linker will look for a file named libruby1.8.so in the standard library locations (probably /usr/lib/ or /usr/local/lib).

Take a look at those directories to see if you have something like that in there.

If not, have you installed the development package of ruby ? If only the linking process fails, I would assume you have (otherwise, it is likely that you wouldn't have the headers as well).

I never linked with ruby, but have you tried specifying -lruby instead of -lruby1.8 ?

Upvotes: 2

Jas
Jas

Reputation: 1141

Have you tried adding the binary to your PATH ?

Upvotes: 0

Related Questions