none
error LNK2005 RRS feed

  • Question

  • I am going to build a plugin for a well known CAD software in the form of a COM dll. For convenience, the CAD vendor has supplied a Visual Studio 10 C++ application wizard so I used that to quickly build the basis. I tested to build it and it worked. Then I added a COM class by using "Project-Add Class-ATL Simple Object". After that it fails when building it. I get some kind of linking error which I cannot find the solution to. I am only a hobby programmer but I have built COM dll's before so I am not a complete novice at least. I hope that someone have som idea of what can be wrong and can share it with me.

    My project is called: KTICP
    The wizard added a COM class called: KTICPAddin
    The COM class I added myself is called: ClutchArmTester

    This is the error message I get when building the project:
    1>KTICP_i.obj : error LNK2005: _IID_IClutchArmTester already defined in KTICP.obj
    1>KTICP_i.obj : error LNK2005: _LIBID_KTICPLib already defined in KTICP.obj
    1>KTICP_i.obj : error LNK2005: _CLSID_KTICPAddin already defined in KTICP.obj
    1>KTICP_i.obj : error LNK2005: _CLSID_ClutchArmTester already defined in KTICP.obj

    The KTICP.idl file looks like this:

    [
    object,
    uuid(F523C797-3220-45EA-95EE-826532448766),
    pointer_default(unique)
    ]
    interface IClutchArmTester : IUnknown{
    };
    [
    uuid(6E99D6C5-8E18-4C0C-9B52-17E0B9DBE700),
    version(1.0),
    helpstring("KTICP 1.0 Type Library")
    ]

    library KTICPLib
    {
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");
    importlib("icapifoundation.tlb");

    [
    uuid(F7EB609F-0A27-454A-BA57-7C885BF46091),
    helpstring("KTICP Addin Object")
    ]
    coclass KTICPAddin
    {
    [default] interface IZAddinServer;
    };

    [
    uuid(88A78CDC-4370-449B-AA53-C7C11CE2D35D),
    helpstring("ClutchArmTester Class")
    ]
    coclass ClutchArmTester
    {
    [default] interface IClutchArmTester;
    };
    }; 

    Thank you very much for any help!

    Thursday, October 1, 2015 6:09 PM

Answers

  • It looks like two different compilation units are defining the same COM items.  From the text of the error message it looks like there are two files in the project that you should check and I am assuming that they have a ".c" extension -- KTICP.c and KTICP_i.c

    I don't know about the code generated by the CAD vendor wizard, but the ATL simple object wizard probably created KTICP_i.c and KTICP_i.h which wlll appear in the "Generated Files" node of Solution Explorer.


    • Edited by RLWA32 Thursday, October 1, 2015 7:06 PM
    • Proposed as answer by RLWA32 Friday, October 2, 2015 6:16 PM
    • Marked as answer by TJARABO Friday, October 2, 2015 6:24 PM
    Thursday, October 1, 2015 7:06 PM
  • 1>KTICP_i.obj : error LNK2005: _IID_IClutchArmTester already defined in KTICP.obj

    This error message mean that you have defined IID_IClutchArmTester in both KTICP.cpp file and KTICP_i.c file.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by TJARABO Friday, October 2, 2015 5:26 PM
    Friday, October 2, 2015 5:39 AM

All replies

  • It looks like two different compilation units are defining the same COM items.  From the text of the error message it looks like there are two files in the project that you should check and I am assuming that they have a ".c" extension -- KTICP.c and KTICP_i.c

    I don't know about the code generated by the CAD vendor wizard, but the ATL simple object wizard probably created KTICP_i.c and KTICP_i.h which wlll appear in the "Generated Files" node of Solution Explorer.


    • Edited by RLWA32 Thursday, October 1, 2015 7:06 PM
    • Proposed as answer by RLWA32 Friday, October 2, 2015 6:16 PM
    • Marked as answer by TJARABO Friday, October 2, 2015 6:24 PM
    Thursday, October 1, 2015 7:06 PM
  • 1>KTICP_i.obj : error LNK2005: _IID_IClutchArmTester already defined in KTICP.obj

    This error message mean that you have defined IID_IClutchArmTester in both KTICP.cpp file and KTICP_i.c file.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by TJARABO Friday, October 2, 2015 5:26 PM
    Friday, October 2, 2015 5:39 AM