# Creating DLL: Problem with Header Files

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

## Recommended Posts

Hi,

I am trying to create a DLL using Microsoft Visual Studio 2010.
My DLL does use another library, so I added the .lib-File of that library to my DLL project and added it's header directory to my DLL's include dir.
No problems so far, but when I want to use my DLL in another project, I need to include the header files of the third-party library again, to get my DLL working properly.

So how do I add the header files of that library to my DLL project so that I don't need to include them again, when using my DLL?

Nokobon

##### Share on other sites
i have my own dlls and us it in another project and i dont need to do that.
odd, im also using VS2010.

what error(s) do you get if you dont include thos other headers ?

##### Share on other sites

i have my own dlls and us it in another project and i dont need to do that.
odd, im also using VS2010.

what error(s) do you get if you dont include thos other headers ?

Does your dlls also depend on other libraries?

My dll depends on the OpenNI library, so when compiling a project that uses my dll I get that error:
error C1083: Cannot open include file: 'XnOpenNI.h': No such file or directory

In my dll I added the OpenNI Include folder to the Include Directories.

I guess I have to put these headers directly into my project, as it is no standard library.
How should I do this?

##### Share on other sites
What Ryan is trying to say is it shouldn't matter if you use third party libraries or not. They are interfacing with the exports that you defined in your DLL; not theirs. Sounds to me like you have exports exposed in your DLL for the third party library. If this is the case then I would create wrapper functions for those specific exports so they are only dealing with your DLL.

##### Share on other sites
Sorry, I don't really get you point...
I want my dll to provide only 3 functions I wrote. The third-party library should be hidden inside completely.
I think I don't have a .def-file, as I exported my functions by using the __declspec(dllexport) keyword.

##### Share on other sites

Sorry, I don't really get you point...
I want my dll to provide only 3 functions I wrote. The third-party library should be hidden inside completely.
I think I don't have a .def-file, as I exported my functions by using the __declspec(dllexport) keyword.

i use this keyword as well

Does your dlls also depend on other libraries?

yes, DirectX

My dll depends on the OpenNI library, so when compiling a project that uses my dll I get that error:
error C1083: Cannot open include file: 'XnOpenNI.h': No such file or directory

In my dll I added the OpenNI Include folder to the Include Directories.

I guess I have to put these headers directly into my project, as it is no standard library.
How should I do this?

i think so, but you should not need to link to them in your other project, what about defineing a "symble" in the preprocessor of your otherproject so that any other projects wont try to include that as that "symble" is not defined.

---edit---
you shoulld use a .def file if you want the code to be more portable to other OS', me im just considering makeing it posible to port to ubuntu / linux but not shure right now(i use a bit of microsoft specifiec code right now)

##### Share on other sites

That's it! I don't need the header in my dll header. There are function declarations that need the header, but these functions are not exported by my dll, so I can put their declaration in the cpp file.
Now it works fine.
In fact it makes sense. Of course the project using my dll needs to know the location of the third-party headers when included in my dll header.

Thanks to both of you!