From: daz Date: 2005-11-02T05:43:06+09:00 Subject: Re: Using LoadLibrary from within an extension From: David Koontz > I am having an issue where LoadLibrary works fine on my system in a normal C > application but not inside an extension (it always returns NULL no matter > what). The same call (translated to dlopen) works fine under linux though so > I'm not sure if it's a specific issue to Windows extensions. For testing > purposes I'm loading a hard coded library but under linux I have also tested > passing in the name and that works fine. Here's the function that's being > called from Ruby along with the relevant variable declarations and imports. > > [...] > > library_handle = LoadLibrary("alleg40.dll"); This dll must be in your Windows PATH or the current working dir. Perhaps, when you ran your C app., they were in the same dir - (the dir from which the app was loaded is added to the search path). From Ruby, the Ruby path is not searched by LoadLibrary but you can use: Dir.chdir('C:\path\to\alleg40') before: require 'my_ext' ... which sets the current working dir (also added to the search path). I don't know of any other issue that could cause the load to fail. daz (btw: not a -core issue ... [ruby-talk] knows C ;)