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

PJ Durai pjdtech2000 at gmail.com
Tue Jul 15 17:51:09 EDT 2008


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 `AdsConnect at 8'
adsapi.o(.text+0x260):fake: undefined reference to `AdsDisconnect at 4'
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


More information about the Haskell-Cafe mailing list