仅在少数方法(静态或共享库)中解析的外部符号
Unresolved external symbol in only a few methods (static or shared library)
这让我发疯,使用 MSVC14.1 我正在制作一个库 A 以用于另一个共享库 B。库 A 是静态的还是共享的并不重要,我总是以 3 个未解析的外部符号结束,如下所示:
[build] GroomDeformer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class avPoly::PolyMesh __cdecl avPoly::PolyMesh::create(class std::vector<struct glm::vec<3,float,0>,class std::allocator<struct glm::vec<3,float,0> > > const &,class std::vector<unsigned int,class std::allocator<unsigned int> > const &,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const &)" (__imp_?create@PolyMesh@avPoly@@SA?AV12@AEBV?$vector@U?$vec@$02M$0A@@glm@@V?$allocator@U?$vec@$02M$0A@@glm@@@std@@@std@@AEBV?$vector@IV?$allocator@I@std@@@4@AEBV?$vector@_KV?$allocator@_K@std@@@4@@Z) referenced in function "public: void __cdecl avGroomCore::GroomDeformer::ConstructMesh(class std::vector<struct glm::vec<3,float,0>,class std::allocator<struct glm::vec<3,float,0> > > const &,class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const &,class std::vector<unsigned int,class std::allocator<unsigned int> > const &)" (?ConstructMesh@GroomDeformer@avGroomCore@@QEAAXAEBV?$vector@U?$vec@$02M$0A@@glm@@V?$allocator@U?$vec@$02M$0A@@glm@@@std@@@std@@AEBV?$vector@_KV?$allocator@_K@std@@@4@AEBV?$vector@IV?$allocator@I@std@@@4@@Z) [C:UserstuftoPycharmProjectsavgroombuildsrccoreCore.vcxproj]
[build] GroomDeformer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class avPoly::FaceLocation __cdecl avPoly::PolyMesh::getClosestLocation(struct glm::vec<3,float,0> const &)" (__imp_?getClosestLocation@PolyMesh@avPoly@@QEAA?AVFaceLocation@2@AEBU?$vec@$02M$0A@@glm@@@Z) referenced in function "public: void __cdecl avGroomCore::GroomDeformer::DeformGroom(void)" (?DeformGroom@GroomDeformer@avGroomCore@@QEAAXXZ) [C:UserstuftoPycharmProjectsavgroombuildsrccoreCore.vcxproj]
[build] GroomDeformer.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: struct glm::vec<3,float,0> __cdecl avPoly::PolyMesh::getAttributeValueFromLocation(class avPoly::FaceLocation const &,class avPoly::Attribute<struct glm::vec<3,float,0> > &)" (__imp_?getAttributeValueFromLocation@PolyMesh@avPoly@@QEAA?AU?$vec@$02M$0A@@glm@@AEBVFaceLocation@2@AEAV?$Attribute@U?$vec@$02M$0A@@glm@@@2@@Z) referenced in function "public: void __cdecl avGroomCore::GroomDeformer::DeformGroom(void)" (?DeformGroom@GroomDeformer@avGroomCore@@QEAAXXZ) [C:UserstuftoPycharmProjectsavgroombuildsrccoreCore.vcxproj]
我不知道现阶段该怎么办。我查看了垃圾箱中的符号,我确实得到了签名,例如:
__imp_?create@PolyMesh@avPoly@@SA?AV12@AEBV?$vector@U?$tvec3@M$0A@@glm@@V?$allocator@U?$tvec3@M$0A@@glm@@@std@@@std@@AEBV?$vector@IV?$allocator@I@std@@@4@AEBV?$vector@_KV?$allocator@_K@std@@@4@@Z
我唯一能注意到的是错误签名中有"tvec3"而不仅仅是"vec"。我认为这是指我必须为库 A GLM 的 typedef,例如:
typedef glm::vec3 Vector3;
typedef std::vector<Vector3> Vector3Array;
关于如何调试它的任何想法或指南?我已经尝试了我能想到的所有方法,但无法将手指放在上面。最糟糕的是,在库 A 项目中,我有另一个迷你可执行文件来测试它,链接很好......(全部使用CMake(。两个 CMake 配置是相同的。
以下是头文件中的方法签名:
AVPOLYLIB_API
static PolyMesh create(Vector3Array const &positions, UIntArray const &faceVertexCounts, IndexArray const &faceVertexIndices);
AVPOLYLIB_API
FaceLocation getClosestLocation(Vector3 const &point);
AVPOLYLIB_API
Vector3 getAttributeValueFromLocation(FaceLocation const & location, Attribute<Vector3> &attribute);
DLL导出如下:
#ifdef AVPOLYLIB_STATIC
#define AVPOLYLIB_API
#else
#ifdef AVPOLYLIB_EXPORTS
#define AVPOLYLIB_API __declspec(dllexport)
#else
#define AVPOLYLIB_API __declspec(dllimport)
#endif
#endif
这些方法中使用的类型是这样声明的(在库命名空间内(:
class FaceLocation {
public:
Index triangleId;
Vector3 barycentricCoordinates;
};
typedef std::vector<Vector3> Vector3Array;
typedef std::vector<Index> IndexArray;
typedef std::vector<unsigned int> UIntArray;
解决了!这很愚蠢:glm 标头存在问题,因为它们在两个库中都有子模块,但由于某种原因版本不匹配。所以我在导出的符号中确实有一个错误的签名。使用同一文件夹中的标头解决了该问题。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 错误 LNK2019:未解析的外部符号"外部"C"此错误是什么?
- 错误 : LNK2019: 未解析的外部符号"外部 "C"