[Haskell-cafe] FFI: newbie linking problem

Olivier Boudry olivier.boudry at gmail.com
Thu May 15 11:03:02 EDT 2008


Hi all,

I found a solution to my linking problem, but it's a bit scary and I'm
wondering if there is a simpler way to do this:

The solution comes from the following article:
    http://www.emmestech.com/moron_guides/moron1.html

To get ghc to link my dll properly I had to do the following:

1. Create a .def file from the sapnwrfc.lib using pexports.exe:
        'pexports sapnwrfc.lib > sapnwrfc.def'

2. Edit the sapnwrfc.def file to add @24 at the end of the function I must
call.
        ...
        RfcSubmitTransaction
        RfcTraceTest
        RfcUTF8ToSAPUC at 24 <-- here
        ...

3. Create a 'sapnwrfc.a' import library using dlltool:
        'dlltool --input-def sapnwrfc.def --dllname sapnwrfc.dll
--output-lib libsapnwrfc.a -k'

Is there a simpler way to do this? Some way of tricking ghc to search for
RfcUTF8ToSAPUC instead of RfcUTF8ToSAPUC at 24. It looks like ghc/ld/gcc
(whoever is responsible) adds a @24 (number depends of args) at the end of
the function name when the function is called using stdcall convention.

Thanks,

Olivier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080515/12db904b/attachment.htm


More information about the Haskell-Cafe mailing list