When I use module in a C++20 project, if I have
// Camera.hpp
extern const unsigned int SCR_WIDTH;
extern const unsigned int SCR_HEIGHT;
And in main.cpp
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
But now I use module,
// Camera.cppm
module;
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
export module Camera;
// extern const unsigned int SCR_WIDTH;
// extern const unsigned int SCR_HEIGHT;
It seems that the linker cannot find the variables, so how should I revise it?
ld.lld: error: undefined symbol: SCR_HEIGHT@Camera
>>> referenced by CMakeFiles/triangle.dir/src/triangle2.cpp.obj:(.refptr._ZW6Camera10SCR_HEIGHT)
ld.lld: error: undefined symbol: SCR_WIDTH@Camera
>>> referenced by CMakeFiles/triangle.dir/src/triangle2.cpp.obj:(.refptr._ZW6Camera9SCR_WIDTH)