1

I want to create a MFC extention dll, my problem is the class that I want use in client include some header file that implemented in my project, now how can use it in client?

For example the header file class that want to export from my dll is like below

#include "classme1.h"
#include "classme2.h"

class AFX_EXT_CLASS dllclass
{
...
//anthor function
};

When I include this header file in client, the client project has error and need two file "classme1.h" and "classme2.h". What I do to solve my problem?

Jabberwocky
  • 40,411
  • 16
  • 50
  • 92
  • My mean is, when you create dll, it's better the client can see one header file not all header file that you implement in your project, for above example I want to add just the header file "dllclass" with client and client don't see another header file. know how can I do it? – saeed Salehi Dec 17 '15 at 11:36

2 Answers2

0

Copy the header files in a common place were both projects can read them.

You can define the path in the #include statement, or you can change the project settings for the C++ pre processor to search the files in different additional directories.

Project settings -> C/C++ -> General -> Additional Include Directories.

For complex projects I very often use the Property Manager. You can define specific settings and add them to your current project. It is just a file that allows you easily to customize projects.

Remember that you also need a reference to the LIB file. It must bes specified in the linker section. Or must be added to the project too. (see tip above).

xMRi
  • 13,897
  • 3
  • 23
  • 50
0

Alternative to xMRi's suggestion is to refactor your extension DLL to remove the need for a client to include your private header files.

Read about PIMPL Idiom (Pointer to IMPLementation), for example here: Why should the "PIMPL" idiom be used?

Community
  • 1
  • 1
Vlad Feinstein
  • 7,028
  • 1
  • 8
  • 18