0

Currently I have some shared class files (.cpp and .h) which I include them in around 20 Projects. Currently I have to include them in all of the projects.

So if I get some business requirements and I change some of the shared (.cpp or .h) files I have to include them in all the 20 Projects which is kind of tedious.

Is there a way where I can create a shared dll or library and include it all of my projects? So if I have to change it, I just have to change it once and then just Add Reference to include that dll or library which contains all the shared (.cpp, .h) files.

I am using VS2012 for VC++.

2
  • Are you having trouble understanding how to create a shared library? Or are you asking if a shared library is an appropriate solution to your problem?
    – RaWz
    Commented Jun 29, 2013 at 10:53
  • @RaWz I am asking if shared library is an appreciate solution for the same? Or is there a better way I am unaware of?
    – JNL
    Commented Jun 29, 2013 at 13:20

1 Answer 1

1

This would be an appropriate use of a shared library. The difference will be that you will need to include a header file and link to the library versus including the headers and cpp files. However, the advantage is that you can build the library once and link to it once rather than having to build the the same code with every project. If you only add classes to the library that don't change much, which are used commonly throughout your code, it will also help to increase the modularity and stability of your programs.

2
  • Can you please elaborate on the steps on how to go for it or from where can I get more details about the same. It will be of great help. Thanks
    – JNL
    Commented Jul 1, 2013 at 14:17
  • How you create a shared library will depend on which platform, ide, and compiler you're using. You should be able to Google shared (or dynamic) library.
    – RaWz
    Commented Jul 3, 2013 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.