[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: extensions on Windows

Kloubakov, Yura

4/12/2005 4:38:00 PM

> -----Original Message-----
> From: Steven Jenkins [mailto:steven.jenkins@ieee.org]
> Sent: Tuesday, April 12, 2005 10:56
>
> This is why I feel I don't speak the language of the country I'm in. I
> installed Microsoft Visual C++ Toolkit 2003, which presumably would
> include the (M)icros(S)oft (V)isual (C) (R)un(T)ime library, but
> doesn't. Of course not--it's in the .NET SDK!
>
> But hey, I'll try it. Thanks for the tip.

You can use DUMPBIN to create a file which lists all exports of a DLL,
reformat this file to .DEF-file using a text editor and then use LIB
to create an import library from the .DEF-file.

Or

You can use IMPLIB utility from Digital Mars to build an import library
from DLL (http://www.digitalmars.com/ctg/i...)
It is in the following package: http://ftp.digitalmars.c...

Yura.
5 Answers

Steven Jenkins

4/12/2005 5:06:00 PM

0

Kloubakov, Yura wrote:
> You can use DUMPBIN to create a file which lists all exports of a DLL,
> reformat this file to .DEF-file using a text editor and then use LIB
> to create an import library from the .DEF-file.
>
> Or
>
> You can use IMPLIB utility from Digital Mars to build an import library
> from DLL (http://www.digitalmars.com/ctg/i...)
> It is in the following package: http://ftp.digitalmars.c...

I over-summarized in my initial message. I was able to use a utility
called impdef, some hand-editing, and dlltool to make a .a that gcc
could like against. At runtime, however, it threw Error 126 or 127,
depending on the location of the DLL. I finally gave up, thinking that
it'd be easier to do it with One-Click Ruby and MSVC.

I'll give the .NET SDK download another hour or so :-(. As long as I'm
here to keep restarting it after the connection resets, it'll finish
eventually.

Thanks for the suggestions.

Steve


Lyndon Samson

4/12/2005 5:55:00 PM

0

You could try the borland free command line compiler, its pretty
comprehensive and has some nice tools included. It just seems to work
alot of the time too :-)




--
Into RFID? www.rfidnewsupdate.com Simple, fast, news.


Steven Jenkins

4/13/2005 6:53:00 AM

0

Steven Jenkins wrote:
> I'll give the .NET SDK download another hour or so :-(. As long as I'm
> here to keep restarting it after the connection resets, it'll finish
> eventually.

That turned out to be a bad wireless card, it seems.

After much setting of environment variables, or whatever Windows calls
things like %LIB% and %INCLUDE%, I can build the .so file.

Here's what 'ruby setup.rb setup' shows me:

---> bin
<--- bin
---> lib
---> lib/jpl
<--- lib/jpl
<--- lib
---> ext
---> ext/jpl
---> ext/jpl/cradle
nmake

Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

cl -nologo -MD -Zi -O2b2xg- -G6 -I.
-Ic:/ruby/lib/ruby/1.8/i386-mswin32
-Ic:/ruby/lib/ruby/1.8/i386-mswin32
-IC:/cygwin/home/sjenkins/ruby-cradle/ext/jpl/cradle -I. -I./..
-I./../missing -c -Tccradleapi.c
cradleapi.c
c:\ruby\bin\ruby -e "puts 'EXPORTS', 'Init_cradle'" >
cradle-i386-mswin32.def
cl -nologo -LD -Fecradle.so cradleapi.obj msvcrt-ruby18.lib
cradleapi.lib oldnames.lib user32.lib advapi32.lib wsock32.lib -link
-incremental:no -debug -opt:ref -opt:icf -dll -libpath:"c:/ruby/lib"
-def:cradle-i386-mswin32.def
Creating library cradle.lib and object cradle.exp
<--- ext/jpl/cradle
<--- ext/jpl
<--- ext

That looks right, I guess. I'm compiling a SWIG wrapper called
cradleapi.c, linking it with the vendor library cradleapi.lib, and
making a shared object called cradle.so.

'ruby setup.rb install' looks reasonable:

---> bin
mkdir -p c:/ruby/bin/
install cradle_demo c:/ruby/bin/
<--- bin
---> lib
mkdir -p c:/ruby/lib/ruby/site_ruby/1.8/
---> lib/jpl
mkdir -p c:/ruby/lib/ruby/site_ruby/1.8/jpl
install cradle.rb c:/ruby/lib/ruby/site_ruby/1.8/jpl
<--- lib/jpl
<--- lib
---> ext
---> ext/jpl
---> ext/jpl/cradle
mkdir -p c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/jpl
install cradle.so c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/jpl
<--- ext/jpl/cradle
<--- ext/jpl
<--- ext

When I try to load the extension, however, I get a "Bad Image" dialog
box that says "The application or DLL [....]\jpl\cradle.so is not a
valid Windows image. Please checdk this against your installation
diskette." I've checked obvious things like permissions, etc.

As far as I can tell, cradle.so is opaque. I have no idea how to tell
what's wrong with it. Any suggestions?

Steve



Lyndon Samson

4/13/2005 7:19:00 AM

0

On 4/13/05, Steven Jenkins <steven.jenkins@ieee.org> wrote:
> Steven Jenkins wrote:
> > I'll give the .NET SDK download another hour or so :-(. As long as I'm
...
>
> When I try to load the extension, however, I get a "Bad Image" dialog
> box that says "The application or DLL [....]\jpl\cradle.so is not a
> valid Windows image. Please checdk this against your installation
> diskette." I've checked obvious things like permissions, etc.
>
> As far as I can tell, cradle.so is opaque. I have no idea how to tell
> what's wrong with it. Any suggestions?
>

The Borland tools include a util called tdump.exe which will analyse
the structure of an executable image ( exe/com/dll ).

I dont know what the non Borland equivilent is, these guys
http://www.heaven... seem to have a GUI program that is
similar, its commercial but you can get a trial.


> Steve
>
>


--
Into RFID? www.rfidnewsupdate.com Simple, fast, news.



Steven Jenkins

4/13/2005 2:56:00 PM

0

Steven Jenkins wrote:
> When I try to load the extension, however, I get a "Bad Image" dialog
> box that says "The application or DLL [....]\jpl\cradle.so is not a
> valid Windows image. Please checdk this against your installation
> diskette." I've checked obvious things like permissions, etc.
>
> As far as I can tell, cradle.so is opaque. I have no idea how to tell
> what's wrong with it. Any suggestions?

This one turned out to be easy, at least after a night's sleep. setup.rb
was truncating the shared object when installing. And indeed, the most
recent setup.rb (3.3.1) implements a binread() method that does the
right thing.

I guess those last 135238 bytes are important.

Steve