From: Zach Dennis Date: 2003-12-03T11:55:58+09:00 Subject: Re: Embedding Ruby in C I got it! Brad you are an inspiration!!! Here's the cl line I got to work: cl test.c /link /LIBPATH:c:\source\ruby-1.8.1 msvcrt-ruby18.lib At first I tried giving an absolute path to the file( "c:\source\ruby-1.8.1\msvcrt-ruby18.lib" ) but later saw an example on the python newsgroup showing the( "c:\source\ruby-1.8.1 msvcrt-ruby18.lib" ). I first tried to link against the msvcrt-ruby18-static.lib because it is almost 3.5mb, but it didn't work. It gave me a bunch more unresolved external symbol errors. The msvcrt-ruby18.lib seemed to do the job and when i was done, i ran it. It worked great!! It was just a simple hello world app. Thanks alot to Brad and Ron for posting their responses. -Zach For any search engines scanning this page: msvc microsoft visual c++ embedding ruby into C program -----Original Message----- From: Brad [mailto:coish@hfx.eastlink.ca] Sent: Tuesday, December 02, 2003 7:07 PM To: ruby-talk ML Subject: Re: Embedding Ruby in C What's the compile command line look like? Seems to me that you're trying to link without telling the compiler where the implementation of ruby_init(), etc. are located. You need to find out what the name of the shared library (or static library, which ever you prefer) for your operating system (For example, on a Linux system the library might be ruby.so or ruby.lib, I don't know what it's actually called :) ) and link that file to your program. e.g. Suppose the library is actually ruby.so Suppose you're using cc for c compiles cc out.c -lruby.so Hope this helps! Sorry I couldn't be more accurate. Regards, Brad Ron Coutts wrote: > > Here is what i get: > > > > Compiling... > > out.c > > Linking... > > 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 > > Debug/out.exe : fatal error LNK1120: 3 unresolved externals > > Error executing link.exe. > > > > out.exe - 4 error(s), 0 warning(s) > > > > Any ideas? Thanks, > > Isn't this just a C linker error? I've never embedded ruby myself, but > it seems there's a missing lib file containing the object code for > functions ruby_init, ruby_finalize and rb_eval_string. > > Ron > >