Is there an example available for C++20 modules distributed as Linux shared libraries?

125 Views Asked by At

I am developing a C++ library that can be installed as a shared object with header files. A new C++20 feature allows that code can also be distributed as C++ modules. One main difference is that with C++ modules, the preprocessor is no longer needed as an interface.

According to this reddit article and its comments, C++ modules are heavily dependent on the compiler, both vendor and version. The modules must not be precompiled, but a .so library is.

The proposed solution seems easy:

You will ship a .so file, and one or many module interface files (...). These are similar to headers, but will not be #included by consumers. Instead, these module interface files will need to be compiled by the user of the library before the module they describe can be imported in the users' source code.

Is there any example code available (yet) that shows how to distribute a Linux shared library based on C++20 modules, gcc 13 and cmake?

I did research on Google and stackoverflow on how to use C++20 modules with cmake for shared libraries, but found nothing appropriate.

0

There are 0 best solutions below