我有一个奇怪的链接器错误,我似乎无法纠正。这个项目实际上是我们系统在 Linux 上的 Windows 端口,所以我们知道在移植到 Windows 之前一切正常。
我正在使用 VS2013(编译良好)将 FTGL(OpenGL 字体库)编译为静态库,并且在 DLL 中使用该静态库。但是,我收到链接器错误,说它找不到符号,据我所知,那里有:
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FTPoint::FTPoint(void)" (__imp_??0FTPoint@@QAE@XZ) referenced in function "public: virtual void __thiscall FPSCounter::draw(class Projector const *)" (?draw@FPSCounter@@UAEXPBVProjector@@@Z) E:\Desktop\libWCLVS\fpsCounter\fpsCounter.obj fpsCounter
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FTPoint::FTPoint(double,double,double)" (__imp_??0FTPoint@@QAE@NNN@Z) referenced in function "public: virtual void __thiscall FPSCounter::draw(class Projector const *)" (?draw@FPSCounter@@UAEXPBVProjector@@@Z) E:\Desktop\libWCLVS\fpsCounter\fpsCounter.obj fpsCounter
"dumpbin.exe /symbols" on the FTGL static lib shows the following (amongst the rest):
1E5 00000000 SECT10 notype () External | ??0FTPoint@@QAE@XZ (public: __thiscall FTPoint::FTPoint(void))
1E6 00000000 SECTE notype () External | ??0FTPoint@@QAE@NNN@Z (public: __thiscall FTPoint::FTPoint(double,double,double))
现在到目前为止,这一直是在单独的 VS 解决方案(两个调试版本)中编译静态库和我的 DLL。如果我将现有的静态库 VS 项目导入到我的 DLL 解决方案中并通过项目的Common Properties -> References
. 这对我来说似乎很奇怪,因为我在不同的解决方案中使用同一个项目,它会编译相同的,因此我应该有相同的未定义符号。
显然,VS 在相同的解决方案中链接它们与导出库然后链接它时做不同的事情。有谁知道我为什么会出现这种行为以及我能做些什么来尝试解决它?