[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Embedding Ruby in C

Zach Dennis

12/2/2003 5:42:00 AM

Thanks for the reply Eric. I checked the defines.h file and it has the line
in it that you suggested. I tried to manually add them to my .c file, but
still no go. Anymore ideas? Here is what I have tried from the command line:

cl out.c
cl out.c -IC:\source\ruby-1.8.1
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\bin
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\lib
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\source\ruby-1.8.1

Each one of the above is giving me the exact same error as before. I've
tried on Windows 2000 and WinXP.

Zach

-----Original Message-----
From: Eric Sunshine [mailto:sunshine@sunshineco.com]
Sent: Tuesday, December 02, 2003 12:10 AM
To: ruby-talk ML
Subject: Re: Embedding Ruby in C


On Tue, 2 Dec 2003 13:15:23 +0900, Zach Dennis wrote:
> out.obj : error LNK2001: unresolved external symbol _ruby_init
> out.obj : error LNK2001: unresolved external symbol _ruby_finalize
> out.obj : error LNK2001: unresolved external symbol _rb_eval_string

Assuming that you are correctly linking against the ruby library, you also
need to ensure that the RUBY_EXTERN macro (1.8.x) is defined properly (or
the
EXTERN macro for ruby 1.6.x). Look inside Ruby's define.h file to see if
this macro is being defined properly for your situation. If it is not, then
you may have to ensure manually that it is defined in an appropriate manner.
For instance, you are using Windows, so:

#define RUBY_EXTERN extern __declspec(dllimport)
#include <ruby.h>

-- ES




1 Answer

Eric Sunshine

12/2/2003 11:43:00 AM

0

On Tue, 2 Dec 2003 14:42:26 +0900, Zach Dennis wrote:
> Thanks for the reply Eric. I checked the defines.h file and it has the line
> in it that you suggested. I tried to manually add them to my .c file, but
> still no go. Here is what I have tried from the command line:
> cl out.c
> cl out.c -IC:\source\ruby-1.8.1
> cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\bin
> cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\lib
> cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\source\ruby-1.8.1
> Each one of the above is giving me the exact same error as before. I've
> tried on Windows 2000 and WinXP.

It does not appear that you are linking with the Ruby library. You need to
link against the library in order for those symbols to be resolved. You
should read the Microsoft documentation to find out how to specify the
library on the command-line. (Based upon my reading, I got the impression
that you can simply specify the library at the end of the command-line after
the other options following /link. You may also need to specify /libpath in
order to let the linker know where the library is.)

Depending upon which version and which binary distribution of Ruby you are
using, the library might be named something like mswin32-ruby18.lib. If you
are using the source code distribution of Ruby then make sure that you have
actually built the project so that the .lib file exists.

At run-time, you may also need to place the Ruby .dll in the same directory
as your .exe file, or make sure that your PATH environment variable mentions
the directory containing the Ruby .dll.

-- ES