0

I have following C/C++ project in VS2017:

  • MySolution

    • MyProject

      • AClass.h,AClass.cpp
        • protected foo(){...};
      • BClass.h,BClass.cpp
      • .....
      • x64\Debug
        • AClass.obj
        • BClass.obj
        • MyProject.lib
        • MyProject.dll
    • MyProjectTest

      • AClassTest.cpp

This is project setting:

  • MyProjectTest setting :
    • Add reference to MyProject
    • Configuration Properties
      1. C/C++ -> Addtional Include Diretories : ..\MyProjectTest;..\MyProjectTest\x64\Debug
      2. Linker -> General -> Additional Library Directories -> : ..\MyProjectTest\x64\Debug
      3. Linker -> Input -> Additional Dependencies -> : MyProject.lib

This is how I test protected foo() :

include "AClass.h"
class AClassTest : AClass {
   public:
   void wrapFoo() {
     return foo(); //Call AClass::foo()
   }
}

When I build Solution, I got this error :

 AClasstest.obj : error LNK2019: unresolved external symbol "public: __cdecl AClass::~AClass(void)" (??1AClass@@QEAA@XZ) 
    referenced in function "public: __cdecl AClassTest::~AClassTest(void)" (??AClassTest@@QEAA@XZ)

 AClasstest.obj : error LNK2019: unresolved external symbol "public: __cdecl AClass::foo(void)" (??1AClass@@QEAA@XZ) 
referenced in function "public: __cdecl AClassTest::wrapFoo(void)" (??foo@AClassTest@@QEAA@XZ)

I known that so many question about this problem. I was try with some accepted answer but still no luck

Are there any missing setting in MyProjectTest?

Ryo
  • 995
  • 2
  • 25
  • 41
  • You don't show the code for `AClass`, but it appears you've told the compiler that you'll define the destructor for `AClass` but don't define it anyplace (or don't link with the source module that contains the definition). – 1201ProgramAlarm Dec 06 '19 at 03:31
  • @1201ProgramAlarm AClass.cpp was already defined destructor and `foo()` method. But by some way it's could not recognized in from `AClassTest` – Ryo Dec 06 '19 at 09:02

0 Answers0