C#C
C#3y ago
exokem

❔ DllImport From C Library

I have compiled a C library to a DLL and am trying to use some of the functions from this library in a C# project.

C#:
        const string nativeLibName = "FontCache";

        [DllImport(nativeLibName, EntryPoint = "FC_CreateFont", CallingConvention = CallingConvention.Cdecl)]
        static extern unsafe IntPtr INTERNAL_FC_CreateFont();

        [DllImport(nativeLibName, EntryPoint = "FC_LoadFont")]
        static extern unsafe int INTERNAL_FC_LoadFont(
            IntPtr font, 
            IntPtr renderer,
            byte* filename_ttf,
            int pointSize,
            SDL_Color color,
            int style
        );


C:
FC_Font* FC_CreateFont(void);

Uint8 FC_LoadFont(FC_Font* font, SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize, SDL_Color color, int style);


This exception occurs when either of the above functions are called:
An unhandled exception of type 'System.EntryPointNotFoundException' occurred in Xylem-Media.dll: 'Unable to find an entry point named 'FC_CreateFont' in DLL 'FontCache'.'


I don't know if my DllImport signatures are correct, or if there is a problem with the way I have compiled the C library - I have tried using dumpbin and various DLL explorer tools to see which symbols are available but nothing ever appears under the module I am targeting.
Was this page helpful?