GHC FFI for windows: undefined reference to `CreateInstance @ 4 '

I have a super basic test module to try using the Windows DLL:

{-# LANGUAGE ForeignFunctionInterface #-}

module Fface where

import Foreign
import Foreign.C.Types

newtype FFACE = FFACE (Ptr FFACE)

foreign import stdcall unsafe "FFACE4.h CreateInstance"
    c_CreateInstance :: CUInt -> IO (Ptr FFACE)

When I try to compile it into a simple test program, I get the following error:

Linking Main.exe ...
.\Fface.o:fake:(.text+0x18): undefined reference to `CreateInstance@4'
collect2.exe: error: ld returned 1 exit status

Using gendef to list the export list from a DLL, I see that the function is actually exported as "CreateInstance @ 1925", but almost all other functions are exported as just their simple name without the @number stuff. What is @ 1925, and how can I get the GHC to use this instead of @ 4?

+4
source share

Source: https://habr.com/ru/post/1544444/


All Articles