0

In visual studio, one project has the Class A definition.

in header file A.h:

class A{

public:
   void test();
}

in A.cpp file:

void A::test()
{

}

no error here.

But another project when I try to use the test function of A in file B.cpp, there is a link error:

error LNK2019: unresolved external symbol "public: .. A::test() ...

I think here is nothing to do with the namespace. And the other classes defined in the same files as Class A (in A.h and A.cpp) have no problem using in B.cpp. What the possible reasons could be for my situation?

Thanks

lightrek
  • 951
  • 3
  • 14
  • 30
  • 1
    You wrote "But another project when I try to use the test function of A"... Is that really a completely separate project? If so, are you building this project as a library and linking that library into your other project? – aldo Jan 20 '17 at 21:59
  • Presumably you don't link with the object file containing the test() function. –  Jan 20 '17 at 21:59
  • But other classes in the same file as class A have no problem. – lightrek Jan 20 '17 at 22:03
  • Post the real code. –  Jan 20 '17 at 22:08
  • My fault, I forget the __declspec(dllexport) before class A – lightrek Jan 20 '17 at 22:18
  • So, the code in `B.cpp` can see everything in `A.h`, and link to everything in `A.cpp` except `A::test()`, if I understand this correctly. Then, what is different about either `A` or `A::test()`? – Justin Time - Reinstate Monica Jan 20 '17 at 23:28

0 Answers0