locked
Can a COM DLL be statically linked with an EXE? RRS feed

  • Question

  • Scenario:
    ----------------

    I have an EXE application that uses a COM DLL.   Say App.EXE and  COMComponent.DLL.

    Usually whenever there is a change in the COM DLL I send the new COM DLL  and EXE to the client and ask to register the COM DLL manually. 

    Now I am thinking of a way to send only the EXE with the DLL bundled with it so that client does not have to do any manual registration and but the EXE will use the latest COM DLL. 

    Is there any way that the COM component be bundled with EXE (like statically linking), so that the user need not
    specifically update the component manually?  

    Or do I need to change the COM DLL to normal DLL and link statically with it?

    Hope I could describe my problem clearly. 

    Thursday, November 25, 2010 10:37 AM

Answers

  • The very purpose of a COM component is to build a version independent binary component, so I think you are not effectively using the features of COM

    It would be better to go for a regular dll with static linkage or a static library which can be linked to be a part of the EXE.

    But the only problem is , whenever there is a change in the DLL or lib you have rebuild and redistribute the EXE as well.

    By building it as a COM dll, you will not have to recompile the EXE, as long as there are no changes in the COM Interfaces and there is no need to register it either.

    You have to first get the COM Interfaces or the requirements freezed to start working on the code.

     

    regards

    pradish

    • Marked as answer by _San Thursday, November 25, 2010 2:18 PM
    Thursday, November 25, 2010 11:25 AM

All replies

  • The very purpose of a COM component is to build a version independent binary component, so I think you are not effectively using the features of COM

    It would be better to go for a regular dll with static linkage or a static library which can be linked to be a part of the EXE.

    But the only problem is , whenever there is a change in the DLL or lib you have rebuild and redistribute the EXE as well.

    By building it as a COM dll, you will not have to recompile the EXE, as long as there are no changes in the COM Interfaces and there is no need to register it either.

    You have to first get the COM Interfaces or the requirements freezed to start working on the code.

     

    regards

    pradish

    • Marked as answer by _San Thursday, November 25, 2010 2:18 PM
    Thursday, November 25, 2010 11:25 AM
  • Thanks Pradish for the quick response.

    I too agree with your opinion about the COM component. But as I was not sure about whether it is possible or not I decided to know opinions from more experienced users/knowledgeble persons.  I wanted to know whether statically linking the COM DLL possible or not. YES or NO.  From your reply I understand that it is not possible to statically link the COM DLL. 

    If I change the COM DLL, and decide to use regular DLL/static library, I may have to make a lot of changes in the EXE code - replace the existing COM method calls with the calls to exported functions in the regular DLL, right? 

     

    Thanks Pradish again for your quick response and helping.

    Sanil.

    • Marked as answer by _San Thursday, November 25, 2010 2:17 PM
    • Unmarked as answer by _San Thursday, November 25, 2010 2:18 PM
    Thursday, November 25, 2010 1:45 PM
  • If anyone else has more information or a different opinion, kindly let me know.

    Thanks,
    Sanil.

    Thursday, November 25, 2010 2:19 PM
  • Sanil K P wrote:

    Is there any way that the COM component be bundled with EXE (like  statically linking), so that the user need not
    specifically update the component manually?

    If that's what you want, why did you use COM in the first place? What  was the point of breaking your application into two binary modules? Just  take the source code that now goes into the DLL, and build it directly  itno the EXE.

    Or do I need to change the COM DLL to normal DLL and link statically  with it?

    DLL stands for "dynamic link library". You can't link statically to it,  be it a COM or regular DLL.


    Igor Tandetnik

    Thursday, November 25, 2010 6:00 PM
  • Igor Thanks for the reply and valuable information.

    Actually its an existing project that currently uses COM DLL. Now I have been assigned a task to convert that DLL to a library or DLL
    so that I can send only the DLL to a user (whenever a modification is made) and ask the user just overwrite the DLL with the new one.
    Currently the user has to register the DLL (as it is a COM DLL) apart from copying the DLL. What I want in this particular case is avoid
    making the user register COM DLL, whenever a new version is sent.

    Say  a user USER_1 uses an application APP1  which uses the COM DLL.

    Later some modifications are made to the COM DLL. Then this new  modified DLL is  sent to USER_1 and asked hime to register the COM DLL.  If user a fails to register the DLL, then the modified functionalities will not be reflected in APP1.

    If it is a regular DLL (non-COM DLL) the registering can be avoided. USER_1 needs only to copy the DLL to his machine and the APP1 will
    reflect the changes.

    This is why now it is needed to convert the COM DLL to non-COM DLL.

    Thanks Igor for your help and valuable information. 

    Friday, November 26, 2010 12:54 PM
  • Sanil K P wrote:

    Actually its an existing project that currently uses COM DLL. Now I  have been assigned a task to convert that DLL to a library or
    DLL so that I can send only the DLL to a user (whenever a modification is  made) and ask the user just overwrite the DLL with the new
    one.

    You should be able to do just that with the COM DLL you have now. No  special conversion required.

    Currently the user has to register the DLL (as it is a COM DLL)

    The DLL has already been registered before, hans't it? If you just  replace the binary, no one will notice.

    Say a user USER_1 uses an application APP1 which uses the COM DLL.

    Later some modifications are made to the COM DLL. Then this new  modified DLL is sent to USER_1 and asked hime to register the COM
    DLL.

    Don't ask him to register. Just ask him to copy over.

    If user a fails to register the DLL, then the modified functionalities  will not be reflected in APP1.

    That's not true.


    Igor Tandetnik

    Friday, November 26, 2010 3:08 PM
  • Hi Igor,

    Thanks again for improving my knowledge on COM DLLs and patiently responding to my questions.

    I have opted for Registration-Free COM and it looks like it solves my problem. Let me see how it goes.

     

    Thanks,
    Sanil.

    Thursday, December 2, 2010 10:34 AM