Sign in to follow this  
Nokobon

Creating DLL: Problem with Header Files

Recommended Posts

Nokobon    102
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

Share this post


Link to post
Share on other sites
Nokobon    102
[quote name='ryan20fun' timestamp='1307110934' post='4819058']
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 ?
[/quote]

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:
[code]error C1083: Cannot open include file: 'XnOpenNI.h': No such file or directory [/code]

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 this post


Link to post
Share on other sites
UltimaX    468
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.

Share this post


Link to post
Share on other sites
Nokobon    102
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 this post


Link to post
Share on other sites
ryan20fun    2635
[quote name='Nokobon' timestamp='1307133208' post='4819209']
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.
[/quote]

i use this keyword as well

[quote name='Nokobon' timestamp='1307125545' post='4819163']
Does your dlls also depend on other libraries?
[/quote]

yes, DirectX

[quote name='Nokobon' timestamp='1307125545' post='4819163']
My dll depends on the OpenNI library, so when compiling a project that uses my dll I get that error:
[code]error C1083: Cannot open include file: 'XnOpenNI.h': No such file or directory [/code]

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?
[/quote]

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)

Share this post


Link to post
Share on other sites
Nokobon    102
[quote name='ryan20fun' timestamp='1307136116' post='4819225']
do you need to include that header in your header or cant you include that in your source file ?
[/quote]
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this