3

I've got a c++ project called core that compiles successfully and produces a dll and a lib file when compiled on Windows. Now I need to import functionality from core in another project called main. core has a file called core.module.ifc:

export module core
export import :mod
export import :egx
export import :utils

In my main project, I have a single demo.cpp which looks like this:

#include "someOtherLib.h"

import std.core // error occurs here
import core
.....
some other code

However, main does not compile with error:

1>C:\Users\main\Desktop\Projects\demo\src\demo.cpp(8,11): error C2230: could not find module 'core'

I am using VS 16 2019 to compile, with std::c++latest and platform toolset v142. The core.lib file is correctly given as input to the linker in the project's properties. From what I understand, the compiler has no way of knowing that core is an outside library and looks for export module core in the demo project (which obviously fails) and requires a file that has all the declarations of the core lib. Am I correct on this assumption? If so, how would this file look?

So I believe a summary of my question would be, how do I import a module that is exported from a library into my project?

curious student
  • 322
  • 2
  • 11
  • 2
    You may want to read Microsoft's documentation on [VS2019 Modules](https://learn.microsoft.com/en-us/cpp/cpp/modules-cpp?view=vs-2019). – Eljay Feb 01 '20 at 15:32
  • I forgot to enable the compiler modules extension, thanks. Edited my question. – curious student Feb 01 '20 at 17:13

0 Answers0