I've 3 projects in my solution:
Project_I
, Project_A
, Project_B
Project_I contains header files only (no cpp
), this projects defines interfaces in the header files that Project_A
and Projects_B
derive from and implement.
Since I want default behavior in Project_I
interfaces methods to throw NOT_IMPLEMENTED_EXCEPTION (my std::exception subtype)
, for each method declared in any of Project_I
interfaces (header files) I wrote the this implementation in the header files, Also I implemented the C'TORs in the header files.
Now, when I try to compile the solution (after defining the project dependencies and etc...) I get the following error
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl Project_I::ClassA::ClassA()" referenced in function "public: __cdecl Project_B::ClassA_1::ClassA_1 K:\src\Project_B\ClassA_1.obj
Why does the VC++ compiler looks for the .obj
file of ClassA
in project_I
(which needs to be built afterward) if there is no cpp
file at all (the whole implementation is in the header file)?
namespace project_i { //! Histogram class. /*! Image histogram calculator interface class */ class PROJECT_I_API ClassA { public: virtual void Do_Something() { THROW_ERROR(IPM_NOT_SUPPORTED, "Operation is not implemented."); } /*! Default C'TOR */ ClassA(int& _num) : m_num(_num) {} /*! Virtual D'TOR of the object */ virtual ~ClassA(){} protected: int& m_num; }; }
– Hawk89 Apr 29 '15 at 06:04