Reputation: 355
I have a visual studio project called MyKinectDll which I am compiling as a DLL. I have another project called MyKinectApp which is an executable. I have them in the same solution. I have added a dependency from MyKinectApp to MyKinectDll. I have added a reference from MyKinectApp to MyKinectDll. I have added the location of MyKinectDll to the Additional Include Directories of MyKinectApp. Then in my code I have added #include "MyKinect.h", which is one of the headers in MyKinectDll, and it is recognised. But when I compile, only MyKinectDll builds successfully and I get errors in MyKinectApp complaining that there are missing header files. These header files are being called in MyKinect.h and are present elsewhere in MyKinectDll and building correctly on their own.
I am unsure whether I need to link to the .lib of MyKinectDll in linker settings, but I have tried it and I get the same error. What am I doing wrong?
Many thanks for your help.
Upvotes: 0
Views: 299
Reputation: 8709
You need to add the locations of all the headers used by MyKinect.h to the Additional Include Directories for the MyKinectApp project..
This is because you're linking statically (which will link with the lib file, not the dll). The linker needs to look in the header files of the library you're linking to to see the class/method declarations, as they're not available in the lib file.
If you were linking dynamically, the linker could reference the class/function declarations as exported in the dll interface, so you wouldn't need to include the header directories in this case..
Upvotes: 2