0

Linking files is going to be the death of me.

So, I have had this problem many times before in both Visual Studio for C++ and Eclipse for Java. Right now I'm having problems in visual studio while trying to setup a project so I can start messing around with the Kinect SDK. The first thing I did was to include the NuiApi.h

#include <NuiApi.h>

I made sure to go into the VC++ directories and add the correct include directories $(KINECTSDK10_DIR)\inc and $(KINECTSDK10_DIR)\lib\x86 for the library directories. I also went to the Linker and added the Kinect10.lib in the additional dependencies in the Input section.

I still had the problem even after including these directories into the project. So I did some exploring and went to C/C++->General and added the include directories in the "Additional Include Directories" portion again just to see if that would fix it... that did nothing.

So I went back to the linker and added the library directories under General in Additional Library Directories to see if that would do anything and it still has not.

I'm at a complete loss right now and am so confused as to why these files aren't being included correctly! I swear this happens every time I try to work with a new API and I have to fiddle with it until it starts working for some reason. Am I doing something wrong? Am I missing something stupid? Does anyone have any ideas?

MagnusCaligo
  • 707
  • 2
  • 8
  • 28
  • 2
    Reserve angle brackets around include file names for files that are in the compiler's directory tree. I'm not familiar with the Kinect SDK, but most SDKs I have used would not be installed in the compiler's directory tree. Therefore, in this case, I'd try `#include "NuiApi.h"`. Also, the libraries the linker uses generally have nothing to do with the `#include` paths. I wouldn't worry about the libraries until after I had all the `#include`s working. – Logicrat Aug 27 '15 at 19:48
  • @Logicrat I tried doing #include "NuiApi.h" and that worked! However it gave me a bunch of other errors because (I'm assuming) that in the NuiApi.h file there is an #include and because it's in the <> it can only be accessed if it has been added to the project. So in order to fix that I would have to go through all of the .h files and change the #include to #include "whatever.h" – MagnusCaligo Aug 27 '15 at 19:52
  • 1
    I would normally reserve `` for system header files and `"whatever.h"` for user-created header files to avoid the confusion. – John Odom Aug 27 '15 at 20:05
  • 2
    Possibly Kinect is one of those APIs that is designed to be installed in the compiler's tree. However, the choice of the angle brackets or quotes should not actually prevent any files from being found; rather, it should only affect the order in which directories are searched. – Logicrat Aug 27 '15 at 20:06
  • @JohnOdom Oh really? I didn't realize that they acted the same, I thought they were two different forms of syntax and each represented either including files that are in the project or files that are in the include directories... However I still don't have a fix to my problem. The closets fix I can get is if I put all the .h files into the project directory and then include them. However that still doesn't fix my problem like I said before because then I get a bunch of errors in the other files saying that those other files cannot be found – MagnusCaligo Aug 27 '15 at 20:09
  • I was doing some research and found something about moving the SDK from Program Files to Program Files x86... I just tried it and I move the additional directories around to meet the new change however that I didn't change anything. My problem still exists :/ – MagnusCaligo Aug 27 '15 at 20:10
  • 1
    I see you are using an environment variable for the include paths. Did you double check that it is set correctly, and VS was restarted after setting it? – Paul H. Aug 27 '15 at 20:13
  • @PaulH. Yes I have tried both the environment variable and going directly through the file path. Neither has worked – MagnusCaligo Aug 27 '15 at 20:14
  • What boggles my mind even more is that after looking through the sample projects provided by Microsoft, the project properties are almost identical, so why is it that these projects are including the correct files and not mine? – MagnusCaligo Aug 27 '15 at 20:22

1 Answers1

4

The difference between quoted and the angle-bracket form is explained here for visual studio. In principle, the quoted form is used for project specific includes, whereas the angle form is used for system libraries. In your case, the angle-bracket seems to be the right form.

What you have to do is to add the include to the C++ directories :

Right click on project -> Properties 
VC++ directories 

You should keep in mind that this setting is configuration-dependent, i.e. you have to do it for debug mode, but you'll have to repeat it for release mode.

Finally, you should make sure that the environment variable KINECTSDK10_DIR points to the right location (Windows+X -> System -> Advanced system parameters -> Environment variables). Attention: if you edit these parameters, you'll have to restart visual studio so that the new environment is taken into account.

Community
  • 1
  • 1
Christophe
  • 68,716
  • 7
  • 72
  • 138