How to create a plugin from a C library?

Hello everyone,

I am working on a project in Unreal Engine 5 for which I need to use a specific library. This library is called HEALPix, and I would like to create a plugin that uses it in Unreal Engine 5.

Fortunately, the source code for this library is in C++, so I started by downloading it. I then created a plugin folder and a module inside it, containing an ‘include’ folder and a ‘src’ folder. I then copied and pasted all the .h and .cc files into these folders. Finally, I renamed the .cc files to .cpp.

Everything seemed to be working fine until I noticed that HEALPix uses another library called cfitsio. This library is written in C, not C++, and I’m really struggling to implement it as a module for my plugin.

UnrealHEALPix/
    UnrealHEALPix.uplugin
    Resources/
        Icon128.png
    Source/
        cfitsio/
            cfitsio.Build.cs
            include/
                all .h files
            src/
                all .c files
        HEALPix/
            HEALPix.Build.cs
            include/
                all .h files
            src/
                all .cpp files
        UnrealHEALPix/
            UnrealHEALPix.Build.cs
            Private/
            Public/

I noticed that Unreal doesn’t seem to like compiling C files. Also, I get a lot of errors when compiling due to some differences between C and C++.

I’m wondering how to make it work.

If you have any ideas, I would be pleased to read it.