Re: [Haskell-cafe] Linker problems linking FFI import call in Windows

2008-07-16 Thread Olivier Boudry
On Wed, Jul 16, 2008 at 6:22 PM, PJ Durai <[EMAIL PROTECTED]> wrote:
> I do have the import library. It came with the DLL. It links properly
> when I use CCALL on the haskell import statements. Doesnt link when I
> use STDCALL. It looks for  function name with something like '@4 or
> @8' tacked on at the end. Not sure what that is all about.

Is your import library a ".lib" or a ".a" file? If you have a ".lib"
import library ghc will ignore it and link directly with the DLL.

I think you can convert a ".lib" to a ".a" using the reimp tool which
is part of the mingw utilities.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Linker problems linking FFI import call in Windows

2008-07-16 Thread PJ Durai
On 7/16/08, Olivier Boudry <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 15, 2008 at 11:51 PM, PJ Durai <[EMAIL PROTECTED]> wrote:
> > I am trying to import some functions from a windows DLL. I am getting
> > strange errors. (This used to work with previous versions of GHC.  6.6
> > I think.).
>
> You may have to create an import library for the DLL. I had a similar
> problem and solved it that way.
>
> Look at http://www.emmestech.com/moron_guides/moron1.html for advices
> on how to create such a library.
>
> My problem was that the exports in the dll were prefixed with an
> underscore. I had to remove them from the .def file before creating
> the import library.
>
I do have the import library. It came with the DLL. It links properly
when I use CCALL on the haskell import statements. Doesnt link when I
use STDCALL. It looks for  function name with something like '@4 or
@8' tacked on at the end. Not sure what that is all about.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Linker problems linking FFI import call in Windows

2008-07-15 Thread Olivier Boudry
On Tue, Jul 15, 2008 at 11:51 PM, PJ Durai <[EMAIL PROTECTED]> wrote:
> I am trying to import some functions from a windows DLL. I am getting
> strange errors. (This used to work with previous versions of GHC.  6.6
> I think.).

You may have to create an import library for the DLL. I had a similar
problem and solved it that way.

Look at http://www.emmestech.com/moron_guides/moron1.html for advices
on how to create such a library.

My problem was that the exports in the dll were prefixed with an
underscore. I had to remove them from the .def file before creating
the import library.

Best regards,

Olivier.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Linker problems linking FFI import call in Windows

2008-07-15 Thread PJ Durai
Greetings

I am trying to import some functions from a windows DLL. I am getting
strange errors. (This used to work with previous versions of GHC.  6.6
I think.).

This is my import statement:

foreign import stdcall  "ace.h AdsConnect" adsConnect' :: CString ->
Ptr CInt -> IO CInt

This is the build output.

C:\moonar>\bin\make.exe
ghc --make -ffi main.hs  -ffi adsapi.hs -optc -DWIN32 native.cpp  -lace32 -L/hom
e/pjdurai/dev/moonar  -L/tmp/Advantage -o moonar.exe
[1 of 2] Compiling AdsApi   ( adsapi.hs, adsapi.o )
[2 of 2] Compiling Main ( main.hs, main.o )
Linking moonar.exe ...

adsapi.o(.text+0x124):fake: undefined reference to [EMAIL PROTECTED]'
adsapi.o(.text+0x260):fake: undefined reference to [EMAIL PROTECTED]'
collect2: ld returned 1 exit status
make: *** [main.exe] Error 1

It actually links without errors if I use 'ccall' instead of
'stdcall'. But the executable segfaults when the function is called.

I had the same code working with 'stdcall' declaration a while ago.
(With GCH 6.6 I think)

I am using ghc-6.8.3 on Windows XP SP2.

appreciate your time.
thanks
pj
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe