I have a solution called Almond
which contains two projects:
- Almond
- Sandbox
Almond is a shared library created using C++20 modules. Sandbox is supposed to be an executable that links to Almond at runtime (also configured for C++20). I added almond as a reference in Sandbox. It looks like I should be able to import modules from the library and I even get intellisense on it. Do I also have to do things like __declspec(dllexport)
and __declspec(dllimport)
? If so, how? I couldn't find any docs that explained this.
Almond: src/Lib.ixx
export module Lib;
export int Three() {
return 3;
}
Sandbox: src/Main.cpp
:
import Lib;
import <iostream>;
int main() {
std::cout << Three() << std::endl;
}
Almond builds fine but building sandbox gives me the following errors:
Severity Code Description Project File Line Suppression State
Error C2065 'endl': undeclared identifier Sandbox C:\source\Almond\Sandbox\src\Main.cpp 6
Error C2230 could not find module 'Lib' Sandbox C:\source\Almond\Sandbox\src\Main.cpp 1
Error C7612 could not find header unit for 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\iostream' Sandbox C:\source\Almond\Sandbox\src\Main.cpp 3
Error C2039 'cout': is not a member of 'std' Sandbox C:\source\Almond\Sandbox\src\Main.cpp 6
Error C2065 'cout': undeclared identifier Sandbox C:\source\Almond\Sandbox\src\Main.cpp 6
Error C3861 'Three': identifier not found Sandbox C:\source\Almond\Sandbox\src\Main.cpp 6
Error C2039 'endl': is not a member of 'std' Sandbox C:\source\Almond\Sandbox\src\Main.cpp 6