Creating DLL: Problem with Header Files

Started by
6 comments, last by ryan20fun 12 years, 10 months ago
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?

Thanks in advance,
Nokobon
Advertisement
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 ?

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.


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?
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.

So make sure that your .def export file contains your exports.
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.

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.

do you need to include that header in your header or cant you include that in your source file ?

---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)

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.


do you need to include that header in your header or cant you include that in your source file ?

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!
just glad i could help :) :) :)

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

This topic is closed to new replies.

Advertisement