Jump to content
  • Advertisement
Sign in to follow this  
deltayoung

[C++] Multiple Headers, a LIB file and a DLL file

This topic is 2992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I would like to share a pool of C++ code to be reused by other program. So what I did was to build it as DLL and LIB files, then pass these files to the developer of that other program for use. On top of that, I also pass a header specifying the class and the methods that he can call. The problem is that, inside this header, there are several dependencies to other non-system header files in my code (all header files are created myself). So far I have no other way than to pass all the related non-system header files to the other program in order to succesfully use my code. I would like to find out, is there a way that I can do to only pass ONE header file, ONE lib and ONE dll file? Passing too many headers may clutter the other program, while I would like to avoid putting all the class/method declarations of the big code into just one header file. In fact, the other program only need to access several methods from this one header file that I want to share. Thank you in advance for any advice!

Share this post


Link to post
Share on other sites
Advertisement
The only thing you can do is try to eliminate unnecessary dependencies from you header file and the DLL interface. But at the end of the day there's no way around including necessary dependencies. Multiple header files aren't really a big issue if that's what you're worried about, since they're just copied once to an include folder and never looked at again. You include one, and it can include the rest. Plus it's a lot easier to chose what bits and pieces of code you really need if everything is split up accordingly.

Share this post


Link to post
Share on other sites
You can use the PIMPL idiom to hide the internal details/dependancies of your classes and just present a clean interface. Then you can distribute the PIMPL-interface headers but leave out the PIMPL-implementation headers.

Share this post


Link to post
Share on other sites
Also note that you can forward declare everything for which the compiler does not need full knowledge. One example being a pointer member "Foobar *p", where you could go in front of your class declaration and write "class Foobar;" instead of "#include <Foobar>".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!