Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error LNK2001

error LNK2001

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comdockerquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rems Kris
    wrote on last edited by
    #1

    Hi, I've created an ActiveX control. The Control class (***Ctl) in it should be derived from a class in another dll (which is also created by me). I want to load the ActiveX control dynamically in a container exe and check if the Ctl class is derived from the base class in the dll (This container is also created by me). The base class in the dll is called TusMacroOcxBase and it is derived from COleControl. The Ctl class in the ActiveX control which is derived from TusMacroOcxBase is called CTusSampleOcxCtrl. I decided to make use of CRuntime class's methods to check the class type information (Since COleControl is already derived from CObject). So I proceeded by using the DECLARE_DYNAMIC/DECLARE_DYNCREATE and IMPLEMENT_DYNAMIC/IMPLEMENT_DYNCREATE macros. I also enabled RTTI in the container exe. My problem is that when I write IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, TusMacroOcxBase) in CTusSampleOcxCtrl class's .cpp file, it gives error LNK2001. The error message is given below. TusSampleOcxCtl.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const TusMacroOcxBase::classTusMacroOcxBase" (?classTusMacroOcxBase@TusMacroOcxBase@@2UCRuntimeClass@@B) Here is the code snippet: Base class - .h class _declspec(dllexport) TusMacroOcxBase : public COleControl { public: DECLARE_DYNAMIC(TusMacroOcxBase) .... Base class - .cpp IMPLEMENT_DYNAMIC( TusMacroOcxBase, COleControl ) Derived class - .h class CTusSampleOcxCtrl : public TusMacroOcxBase { DECLARE_DYNCREATE(CTusSampleOcxCtrl) .... Derived class - .cpp IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, TusMacroOcxBase) I can solve the error easily by replacing IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, TusMacroOcxBase) with IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, COleControl), but I cant do that since I need to get the exact base class of CTusSampleOcxCtrl in the container exe. If I give COleControl there, I will get the base class as COleControl only. Is there any other way? I've tried different combinations of DECLARE_DYNAMIC/DECLARE_DYNCREATE and IMPLEMENT_DYNAMIC/IMPLEMENT_DYNCREATE also. Any help will be greatly appreciated. Thanks in advance, Rems.

    R 1 Reply Last reply
    0
    • R Rems Kris

      Hi, I've created an ActiveX control. The Control class (***Ctl) in it should be derived from a class in another dll (which is also created by me). I want to load the ActiveX control dynamically in a container exe and check if the Ctl class is derived from the base class in the dll (This container is also created by me). The base class in the dll is called TusMacroOcxBase and it is derived from COleControl. The Ctl class in the ActiveX control which is derived from TusMacroOcxBase is called CTusSampleOcxCtrl. I decided to make use of CRuntime class's methods to check the class type information (Since COleControl is already derived from CObject). So I proceeded by using the DECLARE_DYNAMIC/DECLARE_DYNCREATE and IMPLEMENT_DYNAMIC/IMPLEMENT_DYNCREATE macros. I also enabled RTTI in the container exe. My problem is that when I write IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, TusMacroOcxBase) in CTusSampleOcxCtrl class's .cpp file, it gives error LNK2001. The error message is given below. TusSampleOcxCtl.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const TusMacroOcxBase::classTusMacroOcxBase" (?classTusMacroOcxBase@TusMacroOcxBase@@2UCRuntimeClass@@B) Here is the code snippet: Base class - .h class _declspec(dllexport) TusMacroOcxBase : public COleControl { public: DECLARE_DYNAMIC(TusMacroOcxBase) .... Base class - .cpp IMPLEMENT_DYNAMIC( TusMacroOcxBase, COleControl ) Derived class - .h class CTusSampleOcxCtrl : public TusMacroOcxBase { DECLARE_DYNCREATE(CTusSampleOcxCtrl) .... Derived class - .cpp IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, TusMacroOcxBase) I can solve the error easily by replacing IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, TusMacroOcxBase) with IMPLEMENT_DYNCREATE(CTusSampleOcxCtrl, COleControl), but I cant do that since I need to get the exact base class of CTusSampleOcxCtrl in the container exe. If I give COleControl there, I will get the base class as COleControl only. Is there any other way? I've tried different combinations of DECLARE_DYNAMIC/DECLARE_DYNCREATE and IMPLEMENT_DYNAMIC/IMPLEMENT_DYNCREATE also. Any help will be greatly appreciated. Thanks in advance, Rems.

      R Offline
      R Offline
      Rinu_Raj
      wrote on last edited by
      #2

      Please check whether you hav added lib path Project|Properties|Linker|Input|Addition al Dependencies. Rinu Raj

      R 1 Reply Last reply
      0
      • R Rinu_Raj

        Please check whether you hav added lib path Project|Properties|Linker|Input|Addition al Dependencies. Rinu Raj

        R Offline
        R Offline
        Rems Kris
        wrote on last edited by
        #3

        Thanks for your response. I've already added the lib.

        R 1 Reply Last reply
        0
        • R Rems Kris

          Thanks for your response. I've already added the lib.

          R Offline
          R Offline
          Rinu_Raj
          wrote on last edited by
          #4

          is that lib available in path ? if not please add the path what about the header file associated is that compatible with the lib ? Rinu Raj

          R 1 Reply Last reply
          0
          • R Rinu_Raj

            is that lib available in path ? if not please add the path what about the header file associated is that compatible with the lib ? Rinu Raj

            R Offline
            R Offline
            Rems Kris
            wrote on last edited by
            #5

            Yes.lib is available..Header everything is ok..

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups