0

I have developed a C++ DLL named COMMON that contains some externals classes and functions. I have also developed a C++ program that uses this DLL.

When I build C++ program, I include some files from my COMMON DLL. So I have added foldername that contains all .h files (about 20 files) in project's properties.

That's working well.

Now, I have following question

How can I generate automatically a 'big' include that contains all others includes so that in C++ program, I can use directly this include ?

#include "dll-name.h" // include only one BIG DLL file

After DLL has been built, I can distribute it easily in giving only 3 files

dll-name.LIB
dll-name.DLL
dll-name.H

Is there a solution to my problem ?

How can I generate this 'big' DLL include file ?

PS: I use Visual Studio 2017 and pure C++17 without CLI or CLR.

schlebe
  • 3,387
  • 5
  • 37
  • 50
  • 2
    Seriously question what, inside your library header, is required for that interface, vs what is required for your *implementation* in your DLL. The header should only include that which is needed for *it* to be included and compile (linking is a separate commodity) properly by a some arbitrary client. The implementation dependencies go in the .cpp (s) and/or project-only headers, only the mandetory interface requirements go in the distributed lib header. – WhozCraig Apr 29 '19 at 10:27
  • 1
    Create one header file which includes all your header files. Then run that single header file through the preprocessor, and capture the output. There are some problems with that, and that is that the all-in-one header file could take some considerable time to compile. If a user of your DLL doesn't need to use more than a couple of your one-by-one header files, using the all-in-one could be pretty wasteful. – Some programmer dude Apr 29 '19 at 10:27
  • @dude: you have understood what I want. How can I capture output of include file containing all other includes files ? – schlebe Apr 29 '19 at 10:40

1 Answers1

0

you can either send the user a pre preprocessed version of your main header. Or send all your headers to the user.

I assume you want the first option. Make sure you have a COMMON.h file with everything you need included.

If you are using visual studio IDE Open the command line and do.

CL /P /C COMMON.h 

The result will be a huge .i file rename it to a .h file. if you want to preserve some preprocessor directives copy them now to the file. Send it with your DLL or LIB

This way you don't have to send all your headers to the user , you only need to send one.

tomer zeitune
  • 1,080
  • 1
  • 12
  • 14