© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
13 replies
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
        );
        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);
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'.'
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ DllImport a C-Styled array
C#CC# / help
4y ago
❔ C# library usable from python
C#CC# / help
3y ago
DllImport Troubles
C#CC# / help
4y ago