我正在开发 DLL。这是我的 IGlobal.h
,我多次从其他人那里包含它 .h/.cpp
:
#ifndef _IGLOBALS_
#define _IGLOBALS_
struct IGlobalBitmaps {
IBitmap mKnobGeneral;
IBitmap mButtonScore;
IBitmap mButtonRandom;
IBitmap mButtonLoad;
IBitmap mButtonClear;
IBitmap mButtonShape;
IBitmap mSwitchGeneral;
};
IGlobalBitmaps gGlobalBitmaps;
#endif // !_IGLOBALS_
当我编译 DLL 时,它说 LNK1169 one or multiply defined symbols found。
我能做什么?我不能使用 const
(因为一些 IBitmap
方法不是 const),也不能使用 static
(因为它是一个 DLL,它变得很痛苦稍后)。
最佳答案
您应该在 .h 文件中将变量声明为 extern,并在任何一个 cpp 文件中定义它。
关于c++ - 跨 DLL 的全局结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38762703/