views:

86

answers:

3

I have been in this situation quite a few times where visual studio does not honor the Additional Include Directories when it comes to lib and header source files. For example, I just downloaded MyGUI source code and made sure the include directories were correct. I even put them to absolute paths, Visual Studio still complained that it could not find specific header files.

Does anybody experience the same thing with projects, and if so, is there a solution to this problem?Blockquote

EDIT: My apologies for not being able to explain fully. I know that the library and source files have different include directories. The project that I received had correct directory paths for the Additional Include Directories and Additional Library Directories but Visual Studio still failed to recognize them properly. I can right click and open the header file within Visual Studio but when compiling it still complains it cannot find the required header files. I regularly make projects relying on a framework I myself programmed, so I am quite familiar with how to set up dependencies. This is however the second time this seems to be happening. I don't recall which 3rd party project I was trying to compile last time, but Visual Studio simply refused to believe that the Additional Include Directories paths is where it should look for the header files. I am not sure how to give the complete details of this particular library (MyGUI) but I can point you to the website where you can download it to try and see if it is able to find the header files that are included in the project (if it doesn't compile, that is fine, and it is probably because of additional dependencies, but it should at least be able to find files in the common folder, especially when I put absolute paths in Additional Include Directories)

+1  A: 

Can you elaborate on this? If I recall, there are at least two places in Visual Studio where you can configure this:

  1. Per-installation: Tools/Options/Projects and Solutions/VC++ Directories)
  2. Per-project: Project/Properties/Configuration Properties/"C/C++"/General/Additional Include Directories

If you're adding the include directories per-project (#1), which I think you are, and then trying to include from another project, this will obviously not work. Try adding them at the per-installation level and see if it works.

Also, this may sound stupid/simplistic, but make sure the path is right (i.e. copy-paste into Explorer's path bar and see if the header files are in that folder).

André Caron
Actually, I would advise against adding random libraries to the whole environment. A cleaner solution is to just add the needed directories to both projects - you don't really want each and every library lingering around in your environment.
Jim Brissom
It really depends on a number of factors. If you're talking about say, adding Qt - then globally would be wise as chances are you're using that in many projects on the same machine.
Lee
Please see the Edit in my original question for clarification
Samaursa
@Jim: If you're tracking your projects in source control and you can't necessarily guarantee that all developers have installed the library in the same location, then you should not put them in a per-project setting because it will likely cause lots of problems.
André Caron
You shouldn't be using absolute file paths in projects anyway - we use relative file paths + Visual Studio macros that expand to local paths which can be configured for client setups. @Lee: As for Qt and similar libraries, I do agree. But this discussion is digressing the subject of this question.
Jim Brissom
I always avoid absolute paths unless I fail to come up with one properly, in which case I give VS absolute paths then convert them all to relative paths, each time making sure the program compiles. I have found the solution however, which is more of a mistake on my part. Although I would have appreciate a lot if VS warned me about it instead of throwing me off completely.
Samaursa
A: 

If by lib files you mean library (.lib) files, the directory location is not specified through C/C++/General/Additional Include Directories but rather through Linker/General/Additional Library Directories.

It's logical if you think about it. C/C++ options are all compilation options, settings involved with compiling .cpp and .h files. Linker options are all linking options, settings involved with linking up .obj and .lib files.

Marc Bernier
My apologies for not being able to explain fully. I know that the library and source files have different include directories. The project that I received had correct directory paths for the Additional Include Directories and Additional Library Directories but Visual Studio still failed to recognize them properly. I can right click and open the header file within Visual Studio but when compiling it still complains it cannot find the required header files.
Samaursa
I've seen that before - Visual Studio's right-click opens a different include than what is used in the compile. This usually happens when the build fails. After a successful build, this usually doesn't happen. I'd look for same-named include files throughout your include paths, even ones other than the one giving you your problem (could be an include of an include). Also try putting the full path in the #include statement and see if that gets you a little further.
Marc Bernier
A: 

I have found (stumbled) on the solution (I think). It has something to do with the character limit imposed by the OS. Although the limit should be 260, for me it falls in the below 150, see this discussion and links to it. I downloaded and unzipped the file to C:\Users\MyUserName\My Documents\Downloads\Downloads From Chrome\MyGui3.0...[and so on]. I learned quite some time ago not to try to compile projects under such long paths, but this time it completely slipped my mind as VS did not give me a warning at all and pointed me in the wrong direction. Anyway, cutting and pasting the project to D:\ fixed the issue. I am not going to checkmark the answer however until someone confirms this.

Samaursa
Does anyone know if VS imposes a limit on the length of these paths to ensure that, when invoking `cl.exe`, the command line is not too long?
André Caron