Tuft
Tuft

Reputation: 37

Unresolved external symbol in only a few methods (static or shared library)

This is driving me nuts, using MSVC14.1 I am making a library A to be used in another shared library B. It does not matter if the library A is static or shared, I always end up with 3 unresolved external symbols as such :

[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:\Users\tufto\PycharmProjects\avgroom\build\src\core\Core.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:\Users\tufto\PycharmProjects\avgroom\build\src\core\Core.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:\Users\tufto\PycharmProjects\avgroom\build\src\core\Core.vcxproj]

I do not know what to do at this stage. I looked into the symbols from dumpbin and i do get the signatures, for example :

__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

The only thing i can notice is this has "tvec3" instead of just "vec" in the error signature. I think this refers to a typedef i have to GLM for library A such as :

typedef glm::vec3 Vector3;
typedef std::vector<Vector3> Vector3Array;

Any ideas or guidelines on how i could debug this ? I've tried all I can think off and can't put my finger on it. The worst part is that in the library A project i have another mini executable to test it that links just fine... (all using CMake). Both CMake configs are the same.

Here are the method signatures in the header file for these :

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 Export is done as follows :

#ifdef AVPOLYLIB_STATIC
    #define AVPOLYLIB_API
#else
    #ifdef AVPOLYLIB_EXPORTS  
        #define AVPOLYLIB_API __declspec(dllexport)   
    #else  
        #define AVPOLYLIB_API __declspec(dllimport)   
    #endif 
#endif

The types used in these methods are declared like this (inside the library namespace):

class FaceLocation {
        public:
            Index triangleId;
            Vector3 barycentricCoordinates;
};

typedef std::vector<Vector3> Vector3Array;
typedef std::vector<Index> IndexArray;
typedef std::vector<unsigned int> UIntArray;

Upvotes: 1

Views: 725

Answers (1)

Tuft
Tuft

Reputation: 37

Solved it ! It was silly : there was a problem with the glm headers as they where submodules in both libraries but for some reason where not version matching. So i did have a wrong signature in the exported symbols. Using the headers in the same folder solved the issue.

Upvotes: 1

Related Questions