Compiling c files with the Unreal Build System

Hi, I have an external lib that I would like to include as source in a plugin I’m making. The lib is written in straight c and I had a few issues getting the Unreal Build System to compile the module that I’m reporting here as potential bug reports or for people to find via search:

  1. the MODULENAME_API macro does not seem to work with c files (it does not seem to replace the export / import correctly).

  2. because of this you need to wrap exposed functionality in a cpp file to expose something or the .exp file will not be produced and the module compilation will fail

hope this helps someone!

Hi Structure,

Sorry for not responding to your post sooner. Are you still having trouble with this?

The MODULENAME_API macro should work for both C and C++. However, since our module system was created using C++, the macro was never really intended to link to a C library.

What is most likely happening here is that your C library is being correctly included as a dependency, so the macro is set to import. However, because it is a C library, our build system never actually builds the library and the macro is never set to export. That is probably why wrapping your library’s functionality with C++ and using the macro there works fine.

Hi , thanks for the reply. Our C++ wrapper is doing what we need for now. But maybe this something to put into the backlog to make a test case out of compiling a straight c lib in the future.

Thanks!